Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | function test() { |
michael@0 | 5 | waitForExplicitFinish(); |
michael@0 | 6 | |
michael@0 | 7 | let bmFolder = Application.bookmarks.menu.addFolder("keyword-test"); |
michael@0 | 8 | let tab = gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 9 | |
michael@0 | 10 | registerCleanupFunction (function () { |
michael@0 | 11 | bmFolder.remove(); |
michael@0 | 12 | gBrowser.removeTab(tab); |
michael@0 | 13 | }); |
michael@0 | 14 | |
michael@0 | 15 | let bm = bmFolder.addBookmark("bookmarklet", makeURI("javascript:1;")); |
michael@0 | 16 | bm.keyword = "bm"; |
michael@0 | 17 | |
michael@0 | 18 | addPageShowListener(function () { |
michael@0 | 19 | let originalPrincipal = gBrowser.contentPrincipal; |
michael@0 | 20 | |
michael@0 | 21 | // Enter bookmarklet keyword in the URL bar |
michael@0 | 22 | gURLBar.value = "bm"; |
michael@0 | 23 | gURLBar.focus(); |
michael@0 | 24 | EventUtils.synthesizeKey("VK_RETURN", {}); |
michael@0 | 25 | |
michael@0 | 26 | addPageShowListener(function () { |
michael@0 | 27 | ok(gBrowser.contentPrincipal.equals(originalPrincipal), "javascript bookmarklet should inherit principal"); |
michael@0 | 28 | finish(); |
michael@0 | 29 | }); |
michael@0 | 30 | }); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function addPageShowListener(func) { |
michael@0 | 34 | gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() { |
michael@0 | 35 | gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false); |
michael@0 | 36 | func(); |
michael@0 | 37 | }); |
michael@0 | 38 | } |