toolkit/devtools/server/tests/browser/storage-listings.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 Bug 965872 - Storage inspector actor with cookies, local storage and session storage.
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Storage inspector test for listing hosts and storages</title>
michael@0 9 </head>
michael@0 10 <body>
michael@0 11 <iframe src="http://sectest1.example.org/browser/toolkit/devtools/server/tests/browser/storage-unsecured-iframe.html"></iframe>
michael@0 12 <iframe src="https://sectest1.example.org:443/browser/toolkit/devtools/server/tests/browser/storage-secured-iframe.html"></iframe>
michael@0 13 <script type="application/javascript;version=1.7">
michael@0 14
michael@0 15 let partialHostname = location.hostname.match(/^[^.]+(\..*)$/)[1];
michael@0 16 let cookieExpiresTime1 = 2000000000000;
michael@0 17 let cookieExpiresTime2 = 2000000001000;
michael@0 18 // Setting up some cookies to eat.
michael@0 19 document.cookie = "c1=foobar; expires=" +
michael@0 20 new Date(cookieExpiresTime1).toGMTString() + "; path=/browser";
michael@0 21 document.cookie = "cs2=sessionCookie; path=/; domain=" + partialHostname;
michael@0 22 document.cookie = "c3=foobar-2; secure=true; expires=" +
michael@0 23 new Date(cookieExpiresTime2).toGMTString() + "; path=/";
michael@0 24 // ... and some local storage items ..
michael@0 25 localStorage.setItem("ls1", "foobar");
michael@0 26 localStorage.setItem("ls2", "foobar-2");
michael@0 27 // ... and finally some session storage items too
michael@0 28 sessionStorage.setItem("ss1", "foobar-3");
michael@0 29 console.log("added cookies and stuff from main page");
michael@0 30
michael@0 31 function success(event) {
michael@0 32 setupIDB.next(event);
michael@0 33 }
michael@0 34
michael@0 35 window.idbGenerator = function*(callback) {
michael@0 36 let request = indexedDB.open("idb1", 1);
michael@0 37 request.onupgradeneeded = success;
michael@0 38 request.onerror = function(e) {
michael@0 39 throw new Error("error opening db connection");
michael@0 40 };
michael@0 41 let event = yield undefined;
michael@0 42 let db = event.target.result;
michael@0 43 let store1 = db.createObjectStore("obj1", { keyPath: "id" });
michael@0 44 store1.createIndex("name", "name", { unique: false });
michael@0 45 store1.createIndex("email", "email", { unique: true });
michael@0 46 let store2 = db.createObjectStore("obj2", { keyPath: "id2" });
michael@0 47
michael@0 48 store1.add({id: 1, name: "foo", email: "foo@bar.com"}).onsuccess = success;
michael@0 49 yield undefined;
michael@0 50 store1.add({id: 2, name: "foo2", email: "foo2@bar.com"}).onsuccess = success;
michael@0 51 yield undefined;
michael@0 52 store1.add({id: 3, name: "foo2", email: "foo3@bar.com"}).onsuccess = success;
michael@0 53 yield undefined;
michael@0 54 store2.add({id2: 1, name: "foo", email: "foo@bar.com", extra: "baz"}).onsuccess = success;
michael@0 55 yield undefined;
michael@0 56
michael@0 57 store1.transaction.oncomplete = success;
michael@0 58 yield undefined;
michael@0 59 db.close();
michael@0 60
michael@0 61 request = indexedDB.open("idb2", 1);
michael@0 62 request.onupgradeneeded = success;
michael@0 63 event = yield undefined;
michael@0 64
michael@0 65 let db2 = event.target.result;
michael@0 66 let store3 = db2.createObjectStore("obj3", { keyPath: "id3" });
michael@0 67 store3.createIndex("name2", "name2", { unique: true });
michael@0 68 store3.transaction.oncomplete = success;
michael@0 69 yield undefined;
michael@0 70 db2.close();
michael@0 71 console.log("added cookies and stuff from main page");
michael@0 72 callback();
michael@0 73 }
michael@0 74
michael@0 75 function successClear(event) {
michael@0 76 clearIterator.next(event);
michael@0 77 }
michael@0 78
michael@0 79 window.clear = function*(callback) {
michael@0 80 document.cookie = "c1=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
michael@0 81 document.cookie = "c3=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
michael@0 82 localStorage.clear();
michael@0 83 indexedDB.deleteDatabase("idb1").onsuccess = successClear;
michael@0 84 yield undefined;
michael@0 85 indexedDB.deleteDatabase("idb2").onsuccess = successClear;
michael@0 86 yield undefined;
michael@0 87 console.log("removed cookies and stuff from main page");
michael@0 88 callback();
michael@0 89 }
michael@0 90 </script>
michael@0 91 </body>
michael@0 92 </html>

mercurial