mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1108547 - Part 3: Automated tests; r=jdm
This commit is contained in:
parent
5968fd1d7b
commit
e13114bb2b
@ -8,3 +8,8 @@ support-files =
|
|||||||
[browser_bug649778.js]
|
[browser_bug649778.js]
|
||||||
skip-if = e10s # Bug ?????? - leaked until shutdown [nsGlobalWindow #16 about:blank]
|
skip-if = e10s # Bug ?????? - leaked until shutdown [nsGlobalWindow #16 about:blank]
|
||||||
[browser_bug1081537.js]
|
[browser_bug1081537.js]
|
||||||
|
[browser_bug1108547.js]
|
||||||
|
support-files =
|
||||||
|
file_bug1108547-1.html
|
||||||
|
file_bug1108547-2.html
|
||||||
|
file_bug1108547-3.html
|
||||||
|
109
dom/html/test/browser_bug1108547.js
Normal file
109
dom/html/test/browser_bug1108547.js
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
runPass("file_bug1108547-2.html", function() {
|
||||||
|
runPass("file_bug1108547-3.html", function() {
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function runPass(getterFile, finishedCallback) {
|
||||||
|
var rootDir = "http://mochi.test:8888/browser/dom/html/test/";
|
||||||
|
var testBrowser;
|
||||||
|
var privateWin;
|
||||||
|
|
||||||
|
function whenDelayedStartupFinished(win, callback) {
|
||||||
|
let topic = "browser-delayed-startup-finished";
|
||||||
|
Services.obs.addObserver(function onStartup(aSubject) {
|
||||||
|
if (win != aSubject)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Services.obs.removeObserver(onStartup, topic);
|
||||||
|
executeSoon(callback);
|
||||||
|
}, topic, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// First, set the cookie in a normal window.
|
||||||
|
gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug1108547-1.html");
|
||||||
|
gBrowser.selectedBrowser.addEventListener("load", afterOpenCookieSetter, true);
|
||||||
|
|
||||||
|
function afterOpenCookieSetter() {
|
||||||
|
gBrowser.selectedBrowser.removeEventListener("load", afterOpenCookieSetter, true);
|
||||||
|
gBrowser.removeCurrentTab();
|
||||||
|
|
||||||
|
// Now, open a private window.
|
||||||
|
privateWin = OpenBrowserWindow({private: true});
|
||||||
|
whenDelayedStartupFinished(privateWin, afterPrivateWindowOpened);
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterPrivateWindowOpened() {
|
||||||
|
// In the private window, open the getter file, and wait for a new tab to be opened.
|
||||||
|
privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + getterFile);
|
||||||
|
testBrowser = privateWin.gBrowser.selectedBrowser;
|
||||||
|
privateWin.gBrowser.tabContainer.addEventListener("TabOpen", onNewTabOpened, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onNewTabOpened() {
|
||||||
|
// When the new tab is opened, wait for it to load.
|
||||||
|
privateWin.gBrowser.tabContainer.removeEventListener("TabOpen", onNewTabOpened, true);
|
||||||
|
privateWin.gBrowser.tabs[privateWin.gBrowser.tabs.length - 1].linkedBrowser.addEventListener("load", onNewTabLoaded, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onNewTabLoaded() {
|
||||||
|
privateWin.gBrowser.tabs[privateWin.gBrowser.tabs.length - 1].linkedBrowser.removeEventListener("load", onNewTabLoaded, true);
|
||||||
|
|
||||||
|
// Now, ensure that the private tab doesn't have access to the cookie set in normal mode.
|
||||||
|
is(testBrowser.contentDocument.getElementById("result").textContent, "",
|
||||||
|
"Shouldn't have access to the cookies");
|
||||||
|
|
||||||
|
// We're done with the private window, close it.
|
||||||
|
privateWin.close();
|
||||||
|
|
||||||
|
// Clear all cookies.
|
||||||
|
Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager).removeAll();
|
||||||
|
|
||||||
|
// Open a new private window, this time to set a cookie inside it.
|
||||||
|
privateWin = OpenBrowserWindow({private: true});
|
||||||
|
whenDelayedStartupFinished(privateWin, afterPrivateWindowOpened2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterPrivateWindowOpened2() {
|
||||||
|
// In the private window, open the setter file, and wait for it to load.
|
||||||
|
privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + "file_bug1108547-1.html");
|
||||||
|
privateWin.gBrowser.selectedBrowser.addEventListener("load", afterOpenCookieSetter2, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterOpenCookieSetter2() {
|
||||||
|
// We're done with the private window now, close it.
|
||||||
|
privateWin.close();
|
||||||
|
|
||||||
|
// Now try to read the cookie in a normal window, and wait for a new tab to be opened.
|
||||||
|
gBrowser.selectedTab = gBrowser.addTab(rootDir + getterFile);
|
||||||
|
testBrowser = gBrowser.selectedBrowser;
|
||||||
|
gBrowser.tabContainer.addEventListener("TabOpen", onNewTabOpened2, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onNewTabOpened2() {
|
||||||
|
// When the new tab is opened, wait for it to load.
|
||||||
|
gBrowser.tabContainer.removeEventListener("TabOpen", onNewTabOpened2, true);
|
||||||
|
gBrowser.tabs[gBrowser.tabs.length - 1].linkedBrowser.addEventListener("load", onNewTabLoaded2, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onNewTabLoaded2() {
|
||||||
|
gBrowser.tabs[gBrowser.tabs.length - 1].linkedBrowser.removeEventListener("load", onNewTabLoaded2, true);
|
||||||
|
|
||||||
|
// Now, ensure that the normal tab doesn't have access to the cookie set in private mode.
|
||||||
|
is(testBrowser.contentDocument.getElementById("result").textContent, "",
|
||||||
|
"Shouldn't have access to the cookies");
|
||||||
|
|
||||||
|
// Remove both of the tabs opened here.
|
||||||
|
gBrowser.removeCurrentTab();
|
||||||
|
gBrowser.removeCurrentTab();
|
||||||
|
|
||||||
|
finishedCallback();
|
||||||
|
}
|
||||||
|
}
|
4
dom/html/test/file_bug1108547-1.html
Normal file
4
dom/html/test/file_bug1108547-1.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<script>
|
||||||
|
document.cookie = "foo=bar";
|
||||||
|
</script>
|
6
dom/html/test/file_bug1108547-2.html
Normal file
6
dom/html/test/file_bug1108547-2.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<body onload="document.querySelector('form').submit();">
|
||||||
|
<form action="javascript:opener.document.getElementById('result').textContent = document.cookie;" target="_blank">
|
||||||
|
</form>
|
||||||
|
<div id="result">not tested yet</div>
|
||||||
|
</body>
|
5
dom/html/test/file_bug1108547-3.html
Normal file
5
dom/html/test/file_bug1108547-3.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<body onload="document.querySelector('a').click();">
|
||||||
|
<a href="javascript:opener.document.getElementById('result').textContent = document.cookie;" target="_blank">test</a>
|
||||||
|
<div id="result">not tested yet</div>
|
||||||
|
</body>
|
Loading…
Reference in New Issue
Block a user