mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
64 lines
1.5 KiB
HTML
64 lines
1.5 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>localStorage enable preference test</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
<script type="text/javascript">
|
|
|
|
function checkException(func, exc)
|
|
{
|
|
var exceptionThrew = false;
|
|
try {
|
|
func();
|
|
}
|
|
catch (ex) {
|
|
exceptionThrew = true;
|
|
is(ex.name, exc, "Expected "+exc+" exception");
|
|
if (ex.name != exc) {
|
|
ok(true, "The exception which was thrown is: " + ex);
|
|
}
|
|
}
|
|
ok(exceptionThrew, "Exception "+exc+" threw");
|
|
}
|
|
|
|
var storage;
|
|
function test1() {
|
|
is(typeof(window.localStorage), "object", "Storage is present");
|
|
storage = window.localStorage;
|
|
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.storage.enabled", false]]}, test2);
|
|
}
|
|
|
|
function test2() {
|
|
is(window.localStorage, null, "Storage is null");
|
|
|
|
checkException(function() {storage.setItem("test", "value");}, "SecurityError");
|
|
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.storage.enabled", true]]}, test3);
|
|
}
|
|
|
|
function test3() {
|
|
is(typeof(window.localStorage), "object", "Storage is present again");
|
|
storage.setItem("test", "value");
|
|
ok(storage.getItem("test"), "value", "value can be set");
|
|
window.localStorage.clear();
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function doTest() {
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.storage.enabled", true]]}, test1);
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="doTest();">
|
|
|
|
</body>
|
|
</html>
|