Thu, 15 Jan 2015 21:13:52 +0100
Remove forgotten relic of ABI crash risk averse overloaded method change.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | // This test makes sure that the web pages can't register protocol handlers |
michael@0 | 6 | // inside the private browsing mode. |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | // initialization |
michael@0 | 10 | waitForExplicitFinish(); |
michael@0 | 11 | let windowsToClose = []; |
michael@0 | 12 | let notificationValue = "Protocol Registration: testprotocol"; |
michael@0 | 13 | let testURI = "http://example.com/browser/" + |
michael@0 | 14 | "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler_page.html"; |
michael@0 | 15 | |
michael@0 | 16 | function doTest(aIsPrivateMode, aWindow, aCallback) { |
michael@0 | 17 | aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() { |
michael@0 | 18 | aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); |
michael@0 | 19 | |
michael@0 | 20 | setTimeout(function() { |
michael@0 | 21 | let notificationBox = aWindow.gBrowser.getNotificationBox(); |
michael@0 | 22 | let notification = notificationBox.getNotificationWithValue(notificationValue); |
michael@0 | 23 | |
michael@0 | 24 | if (aIsPrivateMode) { |
michael@0 | 25 | // Make sure the notification is correctly displayed without a remember control |
michael@0 | 26 | ok(!notification, "Notification box should not be displayed inside of private browsing mode"); |
michael@0 | 27 | } else { |
michael@0 | 28 | // Make sure the notification is correctly displayed with a remember control |
michael@0 | 29 | ok(notification, "Notification box should be displaying outside of private browsing mode"); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | aCallback(); |
michael@0 | 33 | }, 100); // remember control is added in a setTimeout(0) call |
michael@0 | 34 | }, true); |
michael@0 | 35 | |
michael@0 | 36 | aWindow.gBrowser.selectedBrowser.loadURI(testURI); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function testOnWindow(aOptions, aCallback) { |
michael@0 | 40 | whenNewWindowLoaded(aOptions, function(aWin) { |
michael@0 | 41 | windowsToClose.push(aWin); |
michael@0 | 42 | // execute should only be called when need, like when you are opening |
michael@0 | 43 | // web pages on the test. If calling executeSoon() is not necesary, then |
michael@0 | 44 | // call whenNewWindowLoaded() instead of testOnWindow() on your test. |
michael@0 | 45 | executeSoon(function() aCallback(aWin)); |
michael@0 | 46 | }); |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | // this function is called after calling finish() on the test. |
michael@0 | 50 | registerCleanupFunction(function() { |
michael@0 | 51 | windowsToClose.forEach(function(aWin) { |
michael@0 | 52 | aWin.close(); |
michael@0 | 53 | }); |
michael@0 | 54 | }); |
michael@0 | 55 | |
michael@0 | 56 | // test first when not on private mode |
michael@0 | 57 | testOnWindow({}, function(aWin) { |
michael@0 | 58 | doTest(false, aWin, function() { |
michael@0 | 59 | // then test when on private mode |
michael@0 | 60 | testOnWindow({private: true}, function(aWin) { |
michael@0 | 61 | doTest(true, aWin, finish); |
michael@0 | 62 | }); |
michael@0 | 63 | }); |
michael@0 | 64 | }); |
michael@0 | 65 | } |