mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 687579 part 2: Nuke globalStorage tests. r=jst
This commit is contained in:
parent
89b7db65ac
commit
ed756c20cf
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Child window at test1.example.org</title>
|
||||
<script type="application/javascript">
|
||||
|
||||
function run()
|
||||
{
|
||||
var storage;
|
||||
|
||||
var message = "child-response";
|
||||
|
||||
// This script expects to be loaded as test1.example.org
|
||||
if (window.location.host != "test1.example.org") {
|
||||
message += "\n child not loaded as test1.example.org";
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["test1.example.org"];
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed globalStorage[\"test1.example.org\"]";
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["test1.EXAMPLE.ORG"];
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed globalStorage[\"test1.EXAMPLE.ORG\"]";
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["example.org"];
|
||||
message += "\n passed globalStorage[\"example.org\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["org"];
|
||||
message += "\n passed globalStorage[\"org\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["test2.test1.example.org"];
|
||||
message += "\n passed globalStorage[\"test2.test1.example.org\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage[""];
|
||||
message += "\n passed globalStorage[\"\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
window.parent.postMessage(message, "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,34 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
<title>Child window at sub1.ält.example.org</title>
|
||||
<script type="application/javascript">
|
||||
|
||||
function run()
|
||||
{
|
||||
var storage;
|
||||
|
||||
var message = "child-response";
|
||||
|
||||
// This script expects to be loaded as sub1.ält.example.org
|
||||
if (window.location.host != "sub1.ält.example.org:8000") {
|
||||
message += "\n child not loaded as sub1.ält.example.org:8000";
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["sub1.ält.example.org"];
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed globalStorage[sub1.ält.example.org]";
|
||||
}
|
||||
|
||||
window.parent.postMessage(message, "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,63 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Child window at 127.0.0.1</title>
|
||||
<script type="application/javascript">
|
||||
|
||||
function run()
|
||||
{
|
||||
var storage;
|
||||
|
||||
var message = "child-response";
|
||||
|
||||
try {
|
||||
storage = globalStorage["127.0.0.1"];
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed globalStorage[\"127.0.0.1\"]";
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["126.0.0.1"];
|
||||
message += "\n passed globalStorage[\"126.0.0.1\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["0.0.1"];
|
||||
message += "\n passed globalStorage[\"0.0.1\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["126.0.0"];
|
||||
message += "\n passed globalStorage[\"126.0.0\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["X.126.0.0.1"];
|
||||
message += "\n passed globalStorage[\"X.126.0.0.1\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["X.0.0.1"];
|
||||
message += "\n passed globalStorage[\"X.0.0.1\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
window.parent.postMessage(message, "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,42 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Child window at test1.example.org</title>
|
||||
<script type="application/javascript">
|
||||
|
||||
function run()
|
||||
{
|
||||
var storage;
|
||||
|
||||
var message = "child-response";
|
||||
|
||||
// This script expects to be loaded as test1.example.org
|
||||
if (window.location.host != "test1.example.org") {
|
||||
message += "\n child not loaded as test1.example.org";
|
||||
}
|
||||
|
||||
document.domain = "example.org";
|
||||
|
||||
try {
|
||||
storage = globalStorage["test1.example.org"];
|
||||
message += "\n passed globalStorage[\"test1.example.org\"]";
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
storage = globalStorage["example.org"];
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed globalStorage[\"example.org\"]";
|
||||
}
|
||||
|
||||
window.parent.postMessage(message, "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,152 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Child window for the private browsing test</title>
|
||||
<script type="application/javascript">
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
||||
var _PBSvc = null;
|
||||
function get_PBSvc() {
|
||||
if (_PBSvc)
|
||||
return _PBSvc;
|
||||
|
||||
try {
|
||||
_PBSvc = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
return _PBSvc;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
var storage;
|
||||
|
||||
var message = "child-response";
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
var pb = get_PBSvc();
|
||||
// The private browsing service might not be available
|
||||
if (pb) {
|
||||
try {
|
||||
storage = globalStorage["example.org"];
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed globalStorage[\"example.org\"]";
|
||||
}
|
||||
|
||||
// save Pair-A
|
||||
try {
|
||||
storage.key1 = "value-1";
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed to store Pair-A";
|
||||
}
|
||||
|
||||
// ensure that Pair-A exists
|
||||
try {
|
||||
if (storage.key1 != "value-1")
|
||||
throw "error";
|
||||
}
|
||||
catch (ex) {
|
||||
if (ex == "error")
|
||||
message += "\n Pair-A was not saved correctly";
|
||||
else
|
||||
message += "\n Unexpected exception encountered while checking Pair-A: " + ex;
|
||||
}
|
||||
|
||||
// enter the private browsing mode
|
||||
try {
|
||||
pb.privateBrowsingEnabled = true;
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed to enter the private browsing mode";
|
||||
}
|
||||
|
||||
// ensure that Pair-A does not exist
|
||||
try {
|
||||
// because of bug 426436, |typeof storage.key1 != "undefined"| wouldn't work here
|
||||
if (storage.key1 != "")
|
||||
throw "error";
|
||||
}
|
||||
catch (ex) {
|
||||
if (ex == "error")
|
||||
message += "\n Pair-A existed unexpectedly";
|
||||
else
|
||||
message += "\n Unexpected exception encountered while checking Pair-A (2): " + ex;
|
||||
}
|
||||
|
||||
// attempt to save Pair-B
|
||||
try {
|
||||
storage.key2 = "value-2";
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed to store Pair-B";
|
||||
}
|
||||
|
||||
// ensure that Pair-B exists
|
||||
try {
|
||||
if (storage.key2 != "value-2")
|
||||
throw "error";
|
||||
}
|
||||
catch (ex) {
|
||||
if (ex == "error")
|
||||
message += "\n Pair-B was not retrieved correctly";
|
||||
else
|
||||
message += "\n Unexpected exception encountered while checking Pair-B: " + ex;
|
||||
}
|
||||
|
||||
// exit the private browsing mode
|
||||
try {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
}
|
||||
catch (ex) {
|
||||
message += "\n failed to exit the private browsing mode";
|
||||
}
|
||||
|
||||
// ensure that Pair-A exists
|
||||
try {
|
||||
if (storage.key1 != "value-1")
|
||||
throw "error";
|
||||
}
|
||||
catch (ex) {
|
||||
if (ex == "error")
|
||||
message += "\n Pair-A was not retrieved correctly";
|
||||
else
|
||||
message += "\n Unexpected exception encountered while checking Pair-A (3): " + ex;
|
||||
}
|
||||
|
||||
// ensure that Pair-B does not exist
|
||||
try {
|
||||
// because of bug 426436, |typeof storage.key2 != "undefined"| wouldn't work here
|
||||
if (storage.key2 != "")
|
||||
throw "error";
|
||||
}
|
||||
catch (ex) {
|
||||
if (ex == "error")
|
||||
message += "\n Pair-B existed unexpectedly";
|
||||
else
|
||||
message += "\n Unexpected exception encountered while checking Pair-B (2): " + ex;
|
||||
}
|
||||
}
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
|
||||
window.parent.postMessage(message, "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,43 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=407839
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 407839</title>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=407839">Mozilla Bug 407839</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
|
||||
<iframe name="child" src="http://TEST1.example.org/tests/dom/tests/mochitest/bugs/iframe_bug407839-1.html"></iframe>
|
||||
<iframe name="idn" src="http://sub1.ält.example.org:8000/tests/dom/tests/mochitest/bugs/iframe_bug407839-2.html"></iframe>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Bug 407839 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var gNumMessages = 0;
|
||||
|
||||
function receiveMessage(evt)
|
||||
{
|
||||
is(evt.data, "child-response", "got wrong response");
|
||||
|
||||
if (++gNumMessages == 2) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Cannot get globalStorage objects for partial IP addresses</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
|
||||
<iframe name="child" src="http://127.0.0.1:8888/tests/dom/tests/mochitest/bugs/iframe_bug409349.html"></iframe>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function receiveMessage(evt)
|
||||
{
|
||||
is(evt.origin, "http://127.0.0.1:8888", "wrong sender");
|
||||
ok(evt.source === window.frames.child, "wrong sender");
|
||||
|
||||
is(evt.data, "child-response", "got wrong response");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=424093
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 424093</title>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=424093">Mozilla Bug 424093</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
|
||||
<iframe name="child" src="http://test1.example.org/tests/dom/tests/mochitest/bugs/iframe_bug424093.html"></iframe>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Bug 424093 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function receiveMessage(evt)
|
||||
{
|
||||
is(evt.data, "child-response", "got wrong response");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=463000
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 463000</title>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463000">Mozilla Bug 463000</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
|
||||
<iframe src="http://example.org/tests/dom/tests/mochitest/bugs/iframe_bug463000.html"></iframe>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Bug 463000 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function receiveMessage(evt)
|
||||
{
|
||||
is(evt.data, "child-response", "got wrong response");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -51,9 +51,6 @@ _TEST_FILES = \
|
||||
fullscreen.xul \
|
||||
test_fullscreen_preventdefault.xul \
|
||||
fullscreen_preventdefault.xul \
|
||||
test_domstorage.xul \
|
||||
domstorage_global.xul \
|
||||
domstorage_global.js \
|
||||
focus_window2.xul \
|
||||
focus_frameset.html \
|
||||
child_focus_frame.html \
|
||||
|
@ -1,168 +0,0 @@
|
||||
ok(globalStorage === this["globalStorage"], "globalStorage is global check 1")
|
||||
ok(globalStorage === window["globalStorage"], "globalStorage is global check 2")
|
||||
|
||||
function test_DOMStorage_global()
|
||||
{
|
||||
var currentDomain = "mozilla.com";
|
||||
|
||||
var globalStorage = window.globalStorage;
|
||||
is(globalStorage instanceof StorageList, true, "globalStorage property");
|
||||
|
||||
var storage = globalStorage.namedItem(currentDomain);
|
||||
is(storage instanceof StorageObsolete, true, "StorageList namedItem");
|
||||
|
||||
var storage2 = globalStorage[currentDomain];
|
||||
is(storage2 instanceof StorageObsolete, true, "StorageList property syntax");
|
||||
|
||||
is(storage, storage2, "StorageList namedItem and array return same value");
|
||||
|
||||
// the initial value should be null
|
||||
test_DOMStorage_global_Item(storage, "sample", null, 0, "initial");
|
||||
|
||||
// if no key is supplied, the return value will be null
|
||||
is(storage.getItem("", "Test"), null, "getItem no key");
|
||||
|
||||
exh = false;
|
||||
try {
|
||||
storage.key(0);
|
||||
}
|
||||
catch (ex) { exh = true; }
|
||||
is(exh, true, "key index 0 too high");
|
||||
|
||||
// change the value
|
||||
storage.setItem("sample", "This is the first message");
|
||||
var item = test_DOMStorage_global_Item(storage, "sample", "This is the first message", 1, "setItem");
|
||||
|
||||
// change value using property syntax
|
||||
storage.test = "Second message";
|
||||
test_DOMStorage_global_Item(storage, "test", "Second message", 2, "setItem property");
|
||||
|
||||
// change the first value using property syntax
|
||||
storage.sample = "Third message is this";
|
||||
var item2 = test_DOMStorage_global_Item(storage, "sample", "Third message is this", 2, "setItem property again");
|
||||
|
||||
is(item.value, "Third message is this", "other item reference holds updated value");
|
||||
|
||||
// change the second value using setItem
|
||||
storage.setItem("test", "Look at this, the fourth message");
|
||||
test_DOMStorage_global_Item(storage, "test", "Look at this, the fourth message", 2, "setItem again");
|
||||
|
||||
// don't use this test currently. The spec says that the same object should
|
||||
// always be returned, but this doesn't happen in chrome due to the wrappers
|
||||
// being different
|
||||
// is(item, item2, "same item always returned");
|
||||
|
||||
// using an empty key should not change the value
|
||||
storage.setItem("", "Message Number Five");
|
||||
test_DOMStorage_global_Item(storage, "test", "Look at this, the fourth message", 2, "setItem no key");
|
||||
is(storage.getItem("", "Test"), null, "getItem no key");
|
||||
|
||||
// now test iteration through the keys
|
||||
var key1 = storage.key(0);
|
||||
var key2 = storage.key(1);
|
||||
is(key1 != key2 && (key1 == "sample" || key1 == "test") &&
|
||||
(key2 == "sample" || key2 == "test"), true, "key");
|
||||
exh = false;
|
||||
try {
|
||||
storage.key(2);
|
||||
}
|
||||
catch (ex) { exh = true; }
|
||||
is(exh, true, "key index 2 too high");
|
||||
|
||||
storage.removeItem("sample");
|
||||
test_DOMStorage_global_Item(storage, "sample", null, 1, "removeItem");
|
||||
|
||||
is(item.value, "", "other item reference holds deleted value");
|
||||
|
||||
delete storage.test;
|
||||
test_DOMStorage_global_Item(storage, "test", null, 0, "delete item");
|
||||
|
||||
storage.removeItem("test");
|
||||
|
||||
// now test size constraints
|
||||
|
||||
// create a string which is 1MB - 4 bytes long. The key will use up this
|
||||
// extra 4 bytes though.
|
||||
var stringbit = "---abcdefghijklmnopqrstuvwxyz---";
|
||||
var longstring = "This is quite a long string:";
|
||||
for (var l = 0; l < 32767; l++)
|
||||
longstring += stringbit;
|
||||
|
||||
var s;
|
||||
for (s = 0; s < 5; s++)
|
||||
storage.setItem("key" + s, longstring);
|
||||
|
||||
// at this point, there will be 5MB of data stored, so no more is allowed
|
||||
exh = false;
|
||||
try {
|
||||
storage.setItem("keyfail", "One");
|
||||
}
|
||||
catch (ex) { exh = true; }
|
||||
is(exh, true, "per-domain size constraint");
|
||||
|
||||
// change the first item, to free up space
|
||||
storage.setItem("key1", "This");
|
||||
|
||||
// there is just under 1MB of space available, so this should fail
|
||||
exh = false;
|
||||
try {
|
||||
storage.setItem("keyfail", longstring);
|
||||
}
|
||||
catch (ex) { exh = true; }
|
||||
is(exh, true, "per-domain size constraint second check");
|
||||
|
||||
// now clear up another value, and set it back again
|
||||
storage.removeItem("key2");
|
||||
storage.setItem("key2", longstring);
|
||||
|
||||
// this should still fail
|
||||
exh = false;
|
||||
try {
|
||||
storage.setItem(keyfail, longstring);
|
||||
}
|
||||
catch (ex) { exh = true; }
|
||||
is(exh, true, "per-domain size constraint third check");
|
||||
|
||||
// this should be stored OK
|
||||
storage.setItem("key2", "Simple string");
|
||||
|
||||
for (s = 0; s < 5; s++)
|
||||
storage.removeItem("key" + s);
|
||||
}
|
||||
|
||||
function test_DOMStorage_global_Item(storage, key, expectedvalue, expectedlength, testid)
|
||||
{
|
||||
var item = storage.getItem(key);
|
||||
if (expectedvalue != null)
|
||||
is(item instanceof StorageItem, true, testid + " is a Storage");
|
||||
|
||||
is(expectedvalue == null ? item : "" + item, expectedvalue, testid + " getItem");
|
||||
|
||||
var item2 = storage[key];
|
||||
// skip this check for this test, as the property isn't actually removed
|
||||
if (testid != "removeItem") {
|
||||
if (item === null)
|
||||
is(item2, undefined, testid + " get property syntax");
|
||||
else
|
||||
is(item2, item, testid + " get property syntax");
|
||||
}
|
||||
if (expectedvalue != null)
|
||||
is(item2 instanceof StorageItem, true, testid + " property syntax is a Storage");
|
||||
|
||||
if (expectedvalue != null)
|
||||
is(item.value, expectedvalue, testid + " value");
|
||||
|
||||
is(storage.length, expectedlength, testid + " length");
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
function is(left, right, str)
|
||||
{
|
||||
window.opener.wrappedJSObject.SimpleTest.is(left, right, str);
|
||||
}
|
||||
|
||||
function ok(val, str)
|
||||
{
|
||||
window.opener.wrappedJSObject.SimpleTest.ok(val, str);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
Test for Persistent Storage in chrome
|
||||
-->
|
||||
<window id="sample-window" width="400" height="400"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script src="domstorage_global.js"/>
|
||||
|
||||
<script>
|
||||
test_DOMStorage_global();
|
||||
window.opener.wrappedJSObject.done();
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
|
||||
|
||||
</window>
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
Test for Persistent Storage in chrome
|
||||
-->
|
||||
<window id="sample-window" width="400" height="400"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var newwindow = window.open("domstorage_global.xul", "testwindow", "chrome");
|
||||
|
||||
function done()
|
||||
{
|
||||
SimpleTest.finish();
|
||||
newwindow.close();
|
||||
}
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
|
||||
|
||||
</window>
|
@ -1,54 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2010
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = dom/tests/mochitest/globalstorage
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_bug614116.html \
|
||||
iframe_bug614116-1.html \
|
||||
iframe_bug614116-2.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body onload="loaded()">
|
||||
<script>
|
||||
function loaded() {
|
||||
parent.postMessage("loaded", "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
function onMessageReceived(e) {
|
||||
switch (e.data) {
|
||||
case "getdata":
|
||||
parent.postMessage("data:" + globalStorage["example.com"].data, "http://mochi.test:8888");
|
||||
break;
|
||||
case "setdata":
|
||||
var didSucceed = true;
|
||||
try {
|
||||
globalStorage["example.com"].data = "value2";
|
||||
} catch(e) {
|
||||
didSucceed = false;
|
||||
}
|
||||
parent.postMessage("success:" + didSucceed, "http://mochi.test:8888");
|
||||
parent.postMessage("dataset2:" + globalStorage["example.com"].data, "http://mochi.test:8888");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener("message", onMessageReceived, false);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,24 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body onload="loaded()">
|
||||
<script>
|
||||
function loaded() {
|
||||
parent.postMessage("loaded", "http://mochi.test:8888");
|
||||
}
|
||||
|
||||
function onMessageReceived(e) {
|
||||
switch (e.data) {
|
||||
case "getdata":
|
||||
parent.postMessage("data2:" + globalStorage["example.com"].data, "http://mochi.test:8888");
|
||||
break;
|
||||
case "setdata":
|
||||
globalStorage["example.com"].data = "value";
|
||||
parent.postMessage("dataset:" + globalStorage["example.com"].data, "http://mochi.test:8888");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener("message", onMessageReceived, false);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,85 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=614116
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 614116</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=614116">Mozilla Bug 614116</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe id="http"></iframe>
|
||||
<iframe id="https"></iframe>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 614116 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
const httpDomain = "http://example.com";
|
||||
const httpsDomain = "https://example.com";
|
||||
const path = "/tests/dom/tests/mochitest/globalstorage/";
|
||||
|
||||
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
pm.add(ios.newURI(httpDomain, null, null), "cookie", Components.interfaces.nsICookiePermission.ACCESS_SESSION);
|
||||
pm.add(ios.newURI(httpsDomain, null, null), "cookie", Components.interfaces.nsICookiePermission.ACCESS_SESSION);
|
||||
|
||||
var http = document.getElementById("http");
|
||||
var https = document.getElementById("https");
|
||||
|
||||
function finishTest() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
pm.remove("example.com", "cookie");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var loaded = 0;
|
||||
function onMessageReceived(e) {
|
||||
switch (e.data) {
|
||||
case "loaded":
|
||||
++loaded;
|
||||
ok(loaded <= 2, "Two iframes should be loaded at most");
|
||||
if (loaded == 2) {
|
||||
https.contentWindow.postMessage("setdata", httpsDomain);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (e.data.indexOf("dataset:") == 0) {
|
||||
is(e.data.substr(8), "value", "Correct value should be set");
|
||||
http.contentWindow.postMessage("getdata", httpDomain);
|
||||
} else if (e.data.indexOf("data:") == 0) {
|
||||
is(e.data.substr(5), "undefined", "Data should not be available in HTTP mode");
|
||||
http.contentWindow.postMessage("setdata", httpDomain);
|
||||
} else if (e.data.indexOf("dataset2:") == 0) {
|
||||
is(e.data.substr(9), "undefined", "Correct value should be set");
|
||||
https.contentWindow.postMessage("getdata", httpsDomain);
|
||||
} else if (e.data.indexOf("data2:") == 0) {
|
||||
is(e.data.substr(6), "value", "Data should not be modified in HTTP mode");
|
||||
finishTest();
|
||||
} else if (e.data.indexOf("success:") == 0) {
|
||||
is(e.data.substr(8), "false", "Setting the value in HTTP mode should fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", onMessageReceived, false);
|
||||
|
||||
http.src = httpDomain + path + "iframe_bug614116-1.html";
|
||||
https.src = httpsDomain + path + "iframe_bug614116-2.html";
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,53 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>master frame for event storage propagation</title>
|
||||
|
||||
<script type="text/javascript" src="interOriginFrame.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var currentStep = 1;
|
||||
var gotEvent = false;
|
||||
|
||||
function bind()
|
||||
{
|
||||
document.body.addEventListener("storage", function(event)
|
||||
{
|
||||
gotEvent = true;
|
||||
}, false);
|
||||
}
|
||||
|
||||
function doStep()
|
||||
{
|
||||
switch (currentStep)
|
||||
{
|
||||
case 1:
|
||||
var storage = globalStorage[location.host];
|
||||
storage.setItem("X", "1");
|
||||
storage.setItem("X", "2");
|
||||
storage.setItem("X", "2");
|
||||
storage.removeItem("X");
|
||||
storage.removeItem("X");
|
||||
storage.removeItem("Y");
|
||||
storage.setItem("X", "2");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
todo(gotEvent, false, "Expected no events");
|
||||
return finishTest();
|
||||
}
|
||||
|
||||
// Increase by two to distinguish each test step order
|
||||
// in both master doStep and slave doStep functions.
|
||||
++currentStep;
|
||||
++currentStep;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="bind(); postMsg('frame loaded');">
|
||||
</body>
|
||||
</html>
|
@ -1,56 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>slave for storage event propagation</title>
|
||||
|
||||
<script type="text/javascript" src="interOriginFrame.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var currentStep = 2;
|
||||
|
||||
var events = [];
|
||||
|
||||
function bind()
|
||||
{
|
||||
document.body.addEventListener("storage", function(event)
|
||||
{
|
||||
events.push(event);
|
||||
}, false);
|
||||
}
|
||||
|
||||
function doStep()
|
||||
{
|
||||
function checkEvent()
|
||||
{
|
||||
var event = events.shift();
|
||||
ok(event);
|
||||
if (!event)
|
||||
return;
|
||||
is(event.domain, "example.com");
|
||||
}
|
||||
|
||||
switch (currentStep)
|
||||
{
|
||||
case 2:
|
||||
is(events.length, 4, "Expected 5 events");
|
||||
checkEvent();
|
||||
checkEvent();
|
||||
checkEvent();
|
||||
checkEvent();
|
||||
break;
|
||||
}
|
||||
|
||||
// Increase by two to distinguish each test step order
|
||||
// in both master doStep and slave doStep functions.
|
||||
++currentStep;
|
||||
++currentStep;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="bind(); postMsg('frame loaded');">
|
||||
</body>
|
||||
</html>
|
@ -1,42 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>slave for storage event propagation</title>
|
||||
|
||||
<script type="text/javascript" src="interOriginFrame.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var currentStep = 2;
|
||||
var gotEvent = false;
|
||||
|
||||
function bind()
|
||||
{
|
||||
document.body.addEventListener("storage", function(event)
|
||||
{
|
||||
gotEvent = true;
|
||||
}, false);
|
||||
}
|
||||
|
||||
function doStep()
|
||||
{
|
||||
switch (currentStep)
|
||||
{
|
||||
case 2:
|
||||
is(gotEvent, false, "Expected no events");
|
||||
break;
|
||||
}
|
||||
|
||||
// Increase by two to distinguish each test step order
|
||||
// in both master doStep and slave doStep functions.
|
||||
++currentStep;
|
||||
++currentStep;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="bind(); postMsg('frame loaded');">
|
||||
</body>
|
||||
</html>
|
@ -1,43 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>storage event propagation test</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="interOriginTest2.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<!--
|
||||
This test loads two frames from different
|
||||
origins and checks that entries of localStorage
|
||||
objects don't leak each between other.
|
||||
|
||||
The subsystem is based on postMessage and addEventListener
|
||||
to send messages among different origins. The subsystem waits
|
||||
for both frames be loaded and then alternately calls each frames'
|
||||
doStep() function that on each call proceeds with a single step
|
||||
of the test on its side. This way the subsystem alternate between
|
||||
both frames until both sequences completely finish.
|
||||
-->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function startTest()
|
||||
{
|
||||
masterFrameOrigin = "http://example.com:80";
|
||||
slaveFrameOrigin = "http://example.org:80";
|
||||
|
||||
masterFrame.location = masterFrameOrigin + framePath + "frameGlobalStorageMaster.html";
|
||||
slaveFrame.location = slaveFrameOrigin + framePath + "frameGlobalStorageSlaveNotEqual.html";
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="startTest();">
|
||||
<iframe src="" name="masterFrame"></iframe>
|
||||
<iframe src="" name="slaveFrame"></iframe>
|
||||
</body>
|
||||
</html>
|
@ -1,43 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>storage event propagation test</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="interOriginTest2.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<!--
|
||||
This test loads two frames from different
|
||||
origins and checks that entries of localStorage
|
||||
objects don't leak each between other.
|
||||
|
||||
The subsystem is based on postMessage and addEventListener
|
||||
to send messages among different origins. The subsystem waits
|
||||
for both frames be loaded and then alternately calls each frames'
|
||||
doStep() function that on each call proceeds with a single step
|
||||
of the test on its side. This way the subsystem alternate between
|
||||
both frames until both sequences completely finish.
|
||||
-->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function startTest()
|
||||
{
|
||||
masterFrameOrigin = "http://example.com:80";
|
||||
slaveFrameOrigin = "http://example.com:80";
|
||||
|
||||
masterFrame.location = masterFrameOrigin + framePath + "frameGlobalStorageMaster.html";
|
||||
slaveFrame.location = slaveFrameOrigin + framePath + "frameGlobalStorageSlaveEqual.html";
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="startTest();">
|
||||
<iframe src="" name="masterFrame"></iframe>
|
||||
<iframe src="" name="slaveFrame"></iframe>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user