Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <html xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>localStorage basic test</title> |
michael@0 | 4 | |
michael@0 | 5 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 7 | |
michael@0 | 8 | <script type="text/javascript"> |
michael@0 | 9 | |
michael@0 | 10 | function startTest() |
michael@0 | 11 | { |
michael@0 | 12 | var url = "http://example.com/tests/dom/tests/mochitest/localstorage/frameChromeSlave.html"; |
michael@0 | 13 | var ios = Components.classes["@mozilla.org/network/io-service;1"] |
michael@0 | 14 | .getService(Components.interfaces.nsIIOService); |
michael@0 | 15 | var ssm = Components.classes["@mozilla.org/scriptsecuritymanager;1"] |
michael@0 | 16 | .getService(Components.interfaces.nsIScriptSecurityManager); |
michael@0 | 17 | var dsm = Components.classes["@mozilla.org/dom/localStorage-manager;1"] |
michael@0 | 18 | .getService(Components.interfaces.nsIDOMStorageManager); |
michael@0 | 19 | |
michael@0 | 20 | var uri = ios.newURI(url, "", null); |
michael@0 | 21 | var principal = ssm.getNoAppCodebasePrincipal(uri); |
michael@0 | 22 | var storage = dsm.createStorage(principal, ""); |
michael@0 | 23 | |
michael@0 | 24 | storage.setItem("chromekey", "chromevalue"); |
michael@0 | 25 | |
michael@0 | 26 | var aframe = document.getElementById("aframe"); |
michael@0 | 27 | aframe.onload = function() |
michael@0 | 28 | { |
michael@0 | 29 | is(storage.getItem("chromekey"), "chromevalue"); |
michael@0 | 30 | is(aframe.contentDocument.getElementById("data").innerHTML, "chromevalue"); |
michael@0 | 31 | SimpleTest.finish(); |
michael@0 | 32 | } |
michael@0 | 33 | aframe.src = "http://example.com/tests/dom/tests/mochitest/localstorage/frameChromeSlave.html"; |
michael@0 | 34 | |
michael@0 | 35 | // Additionally check that we do not crash when we access the localStorage |
michael@0 | 36 | // object in the owning chrome window (but we should throw). See bug 485396. |
michael@0 | 37 | var exceptionCaught = false; |
michael@0 | 38 | try { |
michael@0 | 39 | localStorage; |
michael@0 | 40 | } |
michael@0 | 41 | catch (e) { |
michael@0 | 42 | is(e.result, Components.results.NS_ERROR_NOT_AVAILABLE, |
michael@0 | 43 | "Testing that we get the expected exception."); |
michael@0 | 44 | exceptionCaught = true; |
michael@0 | 45 | } |
michael@0 | 46 | is(exceptionCaught, true, "Testing that an exception was thrown."); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 50 | |
michael@0 | 51 | </script> |
michael@0 | 52 | |
michael@0 | 53 | </head> |
michael@0 | 54 | |
michael@0 | 55 | <body onload="startTest();"> |
michael@0 | 56 | <iframe src="" id="aframe"></iframe> |
michael@0 | 57 | </body> |
michael@0 | 58 | </html> |