diff options
Diffstat (limited to 'browser/base/content/test/browser_keywordBookmarklets.js')
-rw-r--r-- | browser/base/content/test/browser_keywordBookmarklets.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/browser/base/content/test/browser_keywordBookmarklets.js b/browser/base/content/test/browser_keywordBookmarklets.js new file mode 100644 index 000000000..8b075d74c --- /dev/null +++ b/browser/base/content/test/browser_keywordBookmarklets.js @@ -0,0 +1,38 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + waitForExplicitFinish(); + + let bmFolder = Application.bookmarks.menu.addFolder("keyword-test"); + let tab = gBrowser.selectedTab = gBrowser.addTab(); + + registerCleanupFunction (function () { + bmFolder.remove(); + gBrowser.removeTab(tab); + }); + + let bm = bmFolder.addBookmark("bookmarklet", makeURI("javascript:1;")); + bm.keyword = "bm"; + + addPageShowListener(function () { + let originalPrincipal = gBrowser.contentPrincipal; + + // Enter bookmarklet keyword in the URL bar + gURLBar.value = "bm"; + gURLBar.focus(); + EventUtils.synthesizeKey("VK_RETURN", {}); + + addPageShowListener(function () { + ok(gBrowser.contentPrincipal.equals(originalPrincipal), "javascript bookmarklet should inherit principal"); + finish(); + }); + }); +} + +function addPageShowListener(func) { + gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() { + gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false); + func(); + }); +} |