content/base/test/browser_bug902350.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial