B2G/gecko/browser/base/content/test/browser_keywordBookmarklets.js
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
Any copyright is dedicated to the Public Domain.
Any copyright is dedicated to the Public Domain .
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;
    gURLBar.value = "bm";
    gURLBar.focus();
    EventUtils.synthesizeKey("VK_RETURN", {});
    addPageShowListener(function () {
      ok(gBrowser.contentPrincipal.equals(originalPrincipal), "javascript bookmarklet should inherit principal");
      finish();
    });
  });
}
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 ; gURLBar . value = "bm" ; gURLBar . focus ( ) ; EventUtils . synthesizeKey ( "VK_RETURN" , { } ) ; addPageShowListener ( function ( ) { ok ( gBrowser . contentPrincipal . equals ( originalPrincipal ) , "javascript bookmarklet should inherit principal" ) ; finish ( ) ; } ) ; } ) ; }
Any copyright is dedicated to the Public Domain.
Any copyright is dedicated to the Public Domain .
// Enter bookmarklet keyword in the URL bar