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

mercurial