toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // ----------------------------------------------------------------------------
     2 // Test whether an InstallTrigger.enabled is working
     3 function test() {
     4   waitForExplicitFinish();
     6   gBrowser.selectedTab = gBrowser.addTab();
     7   gBrowser.selectedBrowser.addEventListener("load", function() {
     8     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
     9     waitForFocus(page_loaded, gBrowser.contentWindow);
    10   }, true);
    11   gBrowser.loadURI(TESTROOT + "bug638292.html");
    12 }
    14 function check_load(aCallback) {
    15   gBrowser.addEventListener("load", function(aEvent) {
    16     if (!gBrowser.browsers[2] ||
    17         aEvent.target != gBrowser.browsers[2].contentDocument) {
    18       // SeaMonkey tabbrowser needs to deal with additional loads.
    19       if (navigator.userAgent.match(/ SeaMonkey\//))
    20         info("Ignoring unrelated load on SeaMonkey. (Expected 2-3 times.)");
    21       else
    22         ok(false, "Ignoring unrelated load on Firefox. (Should never happen!)");
    23       return;
    24     }
    26     gBrowser.removeEventListener("load", arguments.callee, true);
    28     // Let the load handler complete
    29     executeSoon(function() {
    30       var doc = gBrowser.browsers[2].contentDocument;
    31       is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled");
    33       // Focus the old tab
    34       gBrowser.selectedTab = gBrowser.tabs[1];
    35       waitForFocus(function() {
    36         // Close the new tab
    37         gBrowser.removeTab(gBrowser.tabs[2]);
    38         aCallback();
    39       }, gBrowser.contentWindow);
    40     });
    41   }, true);
    42 }
    44 function page_loaded() {
    45   var doc = gBrowser.contentDocument;
    46   info("Clicking link 1");
    47   EventUtils.synthesizeMouseAtCenter(doc.getElementById("link1"), { }, gBrowser.contentWindow);
    49   check_load(function() {
    50     info("Clicking link 2");
    51     EventUtils.synthesizeMouseAtCenter(doc.getElementById("link2"), { }, gBrowser.contentWindow);
    53     check_load(function() {
    54       info("Clicking link 3");
    55       EventUtils.synthesizeMouseAtCenter(doc.getElementById("link3"), { button: 1 }, gBrowser.contentWindow);
    57       check_load(function() {
    58         gBrowser.removeCurrentTab();
    59         finish();
    60       });
    61     });
    62   });
    63 }

mercurial