|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 Iframe for testing multiple host detetion in storage actor |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 </head> |
|
9 <body> |
|
10 <script type="application/javascript;version=1.7"> |
|
11 |
|
12 document.cookie = "sc1=foobar;"; |
|
13 localStorage.setItem("iframe-s-ls1", "foobar"); |
|
14 sessionStorage.setItem("iframe-s-ss1", "foobar-2"); |
|
15 |
|
16 function success(event) { |
|
17 setupIDB.next(event); |
|
18 } |
|
19 |
|
20 window.idbGenerator = function*(callback) { |
|
21 let request = indexedDB.open("idb-s1", 1); |
|
22 request.onupgradeneeded = success; |
|
23 request.onerror = function(e) { |
|
24 throw new Error("error opening db connection"); |
|
25 }; |
|
26 let event = yield undefined; |
|
27 let db = event.target.result; |
|
28 let store1 = db.createObjectStore("obj-s1", { keyPath: "id" }); |
|
29 |
|
30 store1.add({id: 6, name: "foo", email: "foo@bar.com"}).onsuccess = success; |
|
31 yield undefined; |
|
32 store1.add({id: 7, name: "foo2", email: "foo2@bar.com"}).onsuccess = success; |
|
33 yield undefined; |
|
34 store1.transaction.oncomplete = success; |
|
35 yield undefined; |
|
36 db.close(); |
|
37 |
|
38 request = indexedDB.open("idb-s2", 1); |
|
39 request.onupgradeneeded = success; |
|
40 event = yield undefined; |
|
41 |
|
42 let db2 = event.target.result; |
|
43 let store3 = db2.createObjectStore("obj-s2", { keyPath: "id3", autoIncrement: true }); |
|
44 store3.createIndex("name2", "name2", { unique: true }); |
|
45 store3.add({id3: 16, name2: "foo", email: "foo@bar.com"}).onsuccess = success; |
|
46 yield undefined; |
|
47 store3.transaction.oncomplete = success; |
|
48 yield undefined; |
|
49 db2.close(); |
|
50 console.log("added cookies and stuff from secured iframe"); |
|
51 callback(); |
|
52 } |
|
53 |
|
54 function successClear(event) { |
|
55 clearIterator.next(event); |
|
56 } |
|
57 |
|
58 window.clear = function*(callback) { |
|
59 localStorage.clear(); |
|
60 indexedDB.deleteDatabase("idb-s1").onsuccess = successClear; |
|
61 yield undefined; |
|
62 indexedDB.deleteDatabase("idb-s2").onsuccess = successClear; |
|
63 yield undefined; |
|
64 console.log("removed cookies and stuff from secured iframe"); |
|
65 callback(); |
|
66 } |
|
67 </script> |
|
68 </body> |
|
69 </html> |