mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 15:15:23 +00:00
42150d8c10
--HG-- extra : rebase_source : fa49b98e814e84cdde197ec8f872e69db4452d6f
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/* 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();
|
|
});
|
|
}
|