mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 806695 - Port browser_privatebrowsing_protocolhandler.js to the new per-window PB APIs; r=ehsan
--HG-- rename : browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler.js => browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_protocolhandler.js rename : browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html => browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_protocolhandler_page.html
This commit is contained in:
parent
fbbfddb3ae
commit
15ec3de282
@ -31,6 +31,8 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_privatebrowsing_openlocation.js \
|
||||
browser_privatebrowsing_openLocationLastURL.js \
|
||||
browser_privatebrowsing_popupblocker.js \
|
||||
browser_privatebrowsing_protocolhandler.js \
|
||||
browser_privatebrowsing_protocolhandler_page.html \
|
||||
browser_privatebrowsing_theming.js \
|
||||
browser_privatebrowsing_urlbarfocus.js \
|
||||
browser_privatebrowsing_zoomrestore.js \
|
||||
|
@ -0,0 +1,65 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This test makes sure that the web pages can't register protocol handlers
|
||||
// inside the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
waitForExplicitFinish();
|
||||
let windowsToClose = [];
|
||||
let notificationValue = "Protocol Registration: testprotocol";
|
||||
let testURI = "http://example.com/browser/" +
|
||||
"browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_protocolhandler_page.html";
|
||||
|
||||
function doTest(aIsPrivateMode, aWindow, aCallback) {
|
||||
aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||
aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
|
||||
setTimeout(function() {
|
||||
let notificationBox = aWindow.gBrowser.getNotificationBox();
|
||||
let notification = notificationBox.getNotificationWithValue(notificationValue);
|
||||
|
||||
if (aIsPrivateMode) {
|
||||
// Make sure the notification is correctly displayed without a remember control
|
||||
ok(!notification, "Notification box should not be displayed inside of private browsing mode");
|
||||
} else {
|
||||
// Make sure the notification is correctly displayed with a remember control
|
||||
ok(notification, "Notification box should be displaying outside of private browsing mode");
|
||||
}
|
||||
|
||||
aCallback();
|
||||
}, 100); // remember control is added in a setTimeout(0) call
|
||||
}, true);
|
||||
|
||||
aWindow.gBrowser.selectedBrowser.loadURI(testURI);
|
||||
}
|
||||
|
||||
function testOnWindow(aOptions, aCallback) {
|
||||
whenNewWindowLoaded(aOptions, function(aWin) {
|
||||
windowsToClose.push(aWin);
|
||||
// execute should only be called when need, like when you are opening
|
||||
// web pages on the test. If calling executeSoon() is not necesary, then
|
||||
// call whenNewWindowLoaded() instead of testOnWindow() on your test.
|
||||
executeSoon(function() aCallback(aWin));
|
||||
});
|
||||
};
|
||||
|
||||
// this function is called after calling finish() on the test.
|
||||
registerCleanupFunction(function() {
|
||||
windowsToClose.forEach(function(aWin) {
|
||||
aWin.close();
|
||||
});
|
||||
});
|
||||
|
||||
// test first when not on private mode
|
||||
testOnWindow({}, function(aWin) {
|
||||
doTest(false, aWin, function() {
|
||||
// then test when on private mode
|
||||
testOnWindow({private: true}, function(aWin) {
|
||||
doTest(true, aWin, finish);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Protocol registrar page</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
navigator.registerProtocolHandler("testprotocol",
|
||||
"https://example.com/foobar?uri=%s",
|
||||
"Test Protocol");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user