1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/browser/storage-listings.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Bug 965872 - Storage inspector actor with cookies, local storage and session storage. 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Storage inspector test for listing hosts and storages</title> 1.12 +</head> 1.13 +<body> 1.14 +<iframe src="http://sectest1.example.org/browser/toolkit/devtools/server/tests/browser/storage-unsecured-iframe.html"></iframe> 1.15 +<iframe src="https://sectest1.example.org:443/browser/toolkit/devtools/server/tests/browser/storage-secured-iframe.html"></iframe> 1.16 +<script type="application/javascript;version=1.7"> 1.17 + 1.18 +let partialHostname = location.hostname.match(/^[^.]+(\..*)$/)[1]; 1.19 +let cookieExpiresTime1 = 2000000000000; 1.20 +let cookieExpiresTime2 = 2000000001000; 1.21 +// Setting up some cookies to eat. 1.22 +document.cookie = "c1=foobar; expires=" + 1.23 + new Date(cookieExpiresTime1).toGMTString() + "; path=/browser"; 1.24 +document.cookie = "cs2=sessionCookie; path=/; domain=" + partialHostname; 1.25 +document.cookie = "c3=foobar-2; secure=true; expires=" + 1.26 + new Date(cookieExpiresTime2).toGMTString() + "; path=/"; 1.27 +// ... and some local storage items .. 1.28 +localStorage.setItem("ls1", "foobar"); 1.29 +localStorage.setItem("ls2", "foobar-2"); 1.30 +// ... and finally some session storage items too 1.31 +sessionStorage.setItem("ss1", "foobar-3"); 1.32 +console.log("added cookies and stuff from main page"); 1.33 + 1.34 +function success(event) { 1.35 + setupIDB.next(event); 1.36 +} 1.37 + 1.38 +window.idbGenerator = function*(callback) { 1.39 + let request = indexedDB.open("idb1", 1); 1.40 + request.onupgradeneeded = success; 1.41 + request.onerror = function(e) { 1.42 + throw new Error("error opening db connection"); 1.43 + }; 1.44 + let event = yield undefined; 1.45 + let db = event.target.result; 1.46 + let store1 = db.createObjectStore("obj1", { keyPath: "id" }); 1.47 + store1.createIndex("name", "name", { unique: false }); 1.48 + store1.createIndex("email", "email", { unique: true }); 1.49 + let store2 = db.createObjectStore("obj2", { keyPath: "id2" }); 1.50 + 1.51 + store1.add({id: 1, name: "foo", email: "foo@bar.com"}).onsuccess = success; 1.52 + yield undefined; 1.53 + store1.add({id: 2, name: "foo2", email: "foo2@bar.com"}).onsuccess = success; 1.54 + yield undefined; 1.55 + store1.add({id: 3, name: "foo2", email: "foo3@bar.com"}).onsuccess = success; 1.56 + yield undefined; 1.57 + store2.add({id2: 1, name: "foo", email: "foo@bar.com", extra: "baz"}).onsuccess = success; 1.58 + yield undefined; 1.59 + 1.60 + store1.transaction.oncomplete = success; 1.61 + yield undefined; 1.62 + db.close(); 1.63 + 1.64 + request = indexedDB.open("idb2", 1); 1.65 + request.onupgradeneeded = success; 1.66 + event = yield undefined; 1.67 + 1.68 + let db2 = event.target.result; 1.69 + let store3 = db2.createObjectStore("obj3", { keyPath: "id3" }); 1.70 + store3.createIndex("name2", "name2", { unique: true }); 1.71 + store3.transaction.oncomplete = success; 1.72 + yield undefined; 1.73 + db2.close(); 1.74 + console.log("added cookies and stuff from main page"); 1.75 + callback(); 1.76 +} 1.77 + 1.78 +function successClear(event) { 1.79 + clearIterator.next(event); 1.80 +} 1.81 + 1.82 +window.clear = function*(callback) { 1.83 + document.cookie = "c1=; expires=Thu, 01 Jan 1970 00:00:00 GMT"; 1.84 + document.cookie = "c3=; expires=Thu, 01 Jan 1970 00:00:00 GMT"; 1.85 + localStorage.clear(); 1.86 + indexedDB.deleteDatabase("idb1").onsuccess = successClear; 1.87 + yield undefined; 1.88 + indexedDB.deleteDatabase("idb2").onsuccess = successClear; 1.89 + yield undefined; 1.90 + console.log("removed cookies and stuff from main page"); 1.91 + callback(); 1.92 +} 1.93 +</script> 1.94 +</body> 1.95 +</html>