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 private browsing mode disables the remember option |
michael@0 | 6 | // for the popup blocker menu. |
michael@0 | 7 | function test() { |
michael@0 | 8 | // initialization |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | let testURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/popup.html"; |
michael@0 | 12 | let windowsToClose = []; |
michael@0 | 13 | let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load"); |
michael@0 | 14 | gPrefService.setBoolPref("dom.disable_open_during_load", true); |
michael@0 | 15 | |
michael@0 | 16 | function testPopupBlockerMenuItem(aExpectedDisabled, aWindow, aCallback) { |
michael@0 | 17 | |
michael@0 | 18 | aWindow.gBrowser.addEventListener("DOMUpdatePageReport", function() { |
michael@0 | 19 | aWindow.gBrowser.removeEventListener("DOMUpdatePageReport", arguments.callee, false); |
michael@0 | 20 | |
michael@0 | 21 | executeSoon(function() { |
michael@0 | 22 | let notification = aWindow.gBrowser.getNotificationBox().getNotificationWithValue("popup-blocked"); |
michael@0 | 23 | ok(notification, "The notification box should be displayed"); |
michael@0 | 24 | |
michael@0 | 25 | function checkMenuItem(callback) { |
michael@0 | 26 | dump("CMI: in\n"); |
michael@0 | 27 | aWindow.document.addEventListener("popupshown", function(event) { |
michael@0 | 28 | dump("CMI: popupshown\n"); |
michael@0 | 29 | aWindow.document.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 30 | |
michael@0 | 31 | if (aExpectedDisabled) |
michael@0 | 32 | is(aWindow.document.getElementById("blockedPopupAllowSite").getAttribute("disabled"), "true", |
michael@0 | 33 | "The allow popups menu item should be disabled"); |
michael@0 | 34 | |
michael@0 | 35 | event.originalTarget.hidePopup(); |
michael@0 | 36 | dump("CMI: calling back\n"); |
michael@0 | 37 | callback(); |
michael@0 | 38 | dump("CMI: called back\n"); |
michael@0 | 39 | }, false); |
michael@0 | 40 | dump("CMI: out\n"); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | checkMenuItem(function() { |
michael@0 | 44 | aCallback(); |
michael@0 | 45 | }); |
michael@0 | 46 | notification.querySelector("button").doCommand(); |
michael@0 | 47 | }); |
michael@0 | 48 | |
michael@0 | 49 | }, false); |
michael@0 | 50 | |
michael@0 | 51 | aWindow.gBrowser.selectedBrowser.loadURI(testURI); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function finishTest() { |
michael@0 | 55 | // cleanup |
michael@0 | 56 | gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy); |
michael@0 | 57 | finish(); |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | function testOnWindow(options, callback) { |
michael@0 | 61 | let win = whenNewWindowLoaded(options, callback); |
michael@0 | 62 | windowsToClose.push(win); |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | registerCleanupFunction(function() { |
michael@0 | 66 | windowsToClose.forEach(function(win) { |
michael@0 | 67 | win.close(); |
michael@0 | 68 | }); |
michael@0 | 69 | }); |
michael@0 | 70 | |
michael@0 | 71 | testOnWindow({}, function(win) { |
michael@0 | 72 | testPopupBlockerMenuItem(false, win, function() { |
michael@0 | 73 | testOnWindow({private: true}, function(win) { |
michael@0 | 74 | testPopupBlockerMenuItem(true, win, function() { |
michael@0 | 75 | testOnWindow({}, function(win) { |
michael@0 | 76 | testPopupBlockerMenuItem(false, win, finishTest); |
michael@0 | 77 | }) |
michael@0 | 78 | }); |
michael@0 | 79 | }) |
michael@0 | 80 | }); |
michael@0 | 81 | }); |
michael@0 | 82 | } |