Bug 1230563 - Part 2: Test for corrected cookie permission behavior, r=ehsan

This commit is contained in:
Michael Layzell 2015-12-09 15:47:53 -05:00
parent 66890871ee
commit 8fcc59449e
4 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<!doctype html>
<html>
<body>
<script>
parent.postMessage(SpecialPowers.wrap(localStorage).isSessionOnly, "*");
</script>
</body>
</html>

View File

@ -16,6 +16,7 @@ support-files =
interOriginTest.js
interOriginTest2.js
localStorageCommon.js
frameLocalStorageSessionOnly.html
[test_appIsolation.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 793211 # b2g(needs https to work) b2g-debug(needs https to work) b2g-desktop(needs https to work)
@ -56,3 +57,4 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT # b2g(needs https
skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) || toolkit == 'android'
[test_lowDeviceStorage.html]
[test_storageConstructor.html]
[test_localStorageSessionPrefOverride.html]

View File

@ -0,0 +1,54 @@
<html>
<head>
<title>Local Storage Session Pref Override</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script>
const ACCEPT_SESSION = 2;
add_task(function*() {
yield new Promise((resolve, reject) => {
SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy",
ACCEPT_SESSION]]},
resolve);
});
// Before setting permission
yield new Promise((resolve) => {
var frame = document.createElement('iframe');
frame.src = "frameLocalStorageSessionOnly.html";
var listener = (e) => {
is(e.data, true, "Before adding permission should be session only");
window.removeEventListener('message', listener);
resolve();
};
window.addEventListener('message', listener);
document.body.appendChild(frame);
});
// After setting permission
yield new Promise((resolve) => {
SpecialPowers.pushPermissions([{"type": "cookie", "allow": 1, "context": document}],
resolve);
});
yield new Promise((resolve) => {
var frame = document.createElement('iframe');
frame.src = "frameLocalStorageSessionOnly.html";
var listener = (e) => {
is(e.data, false, "After adding permission should not be session only");
window.removeEventListener('message', listener);
resolve();
};
window.addEventListener('message', listener);
document.body.appendChild(frame);
});
});
</script>
</head>
<body>
</body>
</html>

View File

@ -29,4 +29,7 @@ interface Storage {
[Throws]
void clear();
[ChromeOnly]
readonly attribute boolean isSessionOnly;
};