content/base/test/browser_bug902350.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  * Mixed Content Block frame navigates for target="_top" - Test for Bug 902350
     3  */
     6 const PREF_ACTIVE = "security.mixed_content.block_active_content";
     7 const gHttpTestRoot = "https://example.com/tests/content/base/test/";
     8 var origBlockActive;
     9 var gTestBrowser = null;
    11 registerCleanupFunction(function() {
    12   // Set preferences back to their original values
    13   Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive);
    14 });
    16 function MixedTestsCompleted() {
    17   gBrowser.removeCurrentTab();
    18   window.focus();
    19   finish();
    20 }
    22 function test() {
    23   waitForExplicitFinish();
    25   origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
    27   Services.prefs.setBoolPref(PREF_ACTIVE, true);
    29   var newTab = gBrowser.addTab();
    30   gBrowser.selectedTab = newTab;
    31   gTestBrowser = gBrowser.selectedBrowser;
    32   newTab.linkedBrowser.stop()
    34   gTestBrowser.addEventListener("load", MixedTest1A, true);
    35   var url = gHttpTestRoot + "file_bug902350.html";
    36   gTestBrowser.contentWindow.location = url;
    37 }
    39 // Need to capture 2 loads, one for the main page and one for the iframe
    40 function MixedTest1A() {
    41   gTestBrowser.removeEventListener("load", MixedTest1A, true);
    42   gTestBrowser.addEventListener("load", MixedTest1B, true);
    43 }
    45 // Find the iframe and click the link in it
    46 function MixedTest1B() {
    47   gTestBrowser.removeEventListener("load", MixedTest1B, true);
    48   gTestBrowser.addEventListener("load", MixedTest1C, true);
    49   var frame = content.document.getElementById("testing_frame");
    50   var topTarget = frame.contentWindow.document.getElementById("topTarget");
    51   topTarget.click();
    53   // The link click should have caused a load and should not invoke the Mixed Content Blocker
    54   var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser);
    55   ok(!notification, "Mixed Content Doorhanger appears when trying to navigate top");
    57 }
    59 function MixedTest1C() {
    60   gTestBrowser.removeEventListener("load", MixedTest1C, true);
    61   ok(gTestBrowser.contentWindow.location == "http://example.com/", "Navigating to insecure domain through target='_top' failed.")
    62   MixedTestsCompleted();
    63 }

mercurial