mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-07 06:54:33 +00:00
99 lines
3.1 KiB
HTML
99 lines
3.1 KiB
HTML
|
<!DOCTYPE HTML>
|
|||
|
<html>
|
|||
|
<!--
|
|||
|
Bug 965872 - Storage inspector actor with cookies, local storage and session storage.
|
|||
|
-->
|
|||
|
<head>
|
|||
|
<meta charset="utf-8">
|
|||
|
<title>Storage inspector test for listing hosts and storages</title>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<iframe src="http://sectest1.example.org/browser/devtools/server/tests/browser/storage-unsecured-iframe.html"></iframe>
|
|||
|
<script type="application/javascript;version=1.7">
|
|||
|
"use strict";
|
|||
|
const partialHostname = location.hostname.match(/^[^.]+(\..*)$/)[1];
|
|||
|
const cookieExpiresTime1 = 2000000000000;
|
|||
|
const cookieExpiresTime2 = 2000000001000;
|
|||
|
// Setting up some cookies to eat.
|
|||
|
document.cookie = "c1=foobar; expires=" +
|
|||
|
new Date(cookieExpiresTime1).toGMTString() + "; path=/browser";
|
|||
|
document.cookie = "cs2=sessionCookie; path=/; domain=" + partialHostname;
|
|||
|
document.cookie = "c3=foobar-2; expires=" +
|
|||
|
new Date(cookieExpiresTime2).toGMTString() + "; path=/";
|
|||
|
// ... and some local storage items ..
|
|||
|
localStorage.setItem("ls1", "foobar");
|
|||
|
localStorage.setItem("ls2", "foobar-2");
|
|||
|
// ... and finally some session storage items too
|
|||
|
sessionStorage.setItem("ss1", "foobar-3");
|
|||
|
|
|||
|
function success(event) {
|
|||
|
setupIDB.next(event);
|
|||
|
}
|
|||
|
|
|||
|
window.idbGenerator = function*(callback) {
|
|||
|
let request = indexedDB.open("idb1", 1);
|
|||
|
request.onupgradeneeded = success;
|
|||
|
request.onsuccess = success;
|
|||
|
request.onerror = function() {
|
|||
|
throw new Error("error opening db connection");
|
|||
|
};
|
|||
|
let event = yield undefined;
|
|||
|
let db = event.target.result;
|
|||
|
let store1 = db.createObjectStore("obj1", { keyPath: "id" });
|
|||
|
store1.createIndex("name", "name", { unique: false });
|
|||
|
store1.createIndex("email", "email", { unique: true });
|
|||
|
let store2 = db.createObjectStore("obj2", { keyPath: "id2" });
|
|||
|
|
|||
|
store1.add({id: 1, name: "foo", email: "foo@bar.com"}).onsuccess = success;
|
|||
|
yield undefined;
|
|||
|
store1.add({id: 2, name: "foo2", email: "foo2@bar.com"}).onsuccess = success;
|
|||
|
yield undefined;
|
|||
|
store1.add({id: 3, name: "foo2", email: "foo3@bar.com"}).onsuccess = success;
|
|||
|
yield undefined;
|
|||
|
store2.add({
|
|||
|
id2: 1,
|
|||
|
name: "foo",
|
|||
|
email: "foo@bar.com",
|
|||
|
extra: "baz"}).onsuccess = success;
|
|||
|
yield undefined;
|
|||
|
|
|||
|
yield undefined;
|
|||
|
db.close();
|
|||
|
|
|||
|
request = indexedDB.open("idb2", 1);
|
|||
|
request.onupgradeneeded = success;
|
|||
|
request.onsuccess = success;
|
|||
|
event = yield undefined;
|
|||
|
|
|||
|
let db2 = event.target.result;
|
|||
|
let store3 = db2.createObjectStore("obj3", { keyPath: "id3" });
|
|||
|
store3.createIndex("name2", "name2", { unique: true });
|
|||
|
yield undefined;
|
|||
|
db2.close();
|
|||
|
console.log("added cookies and stuff from main page");
|
|||
|
callback();
|
|||
|
};
|
|||
|
|
|||
|
function successClear(event) {
|
|||
|
clearIterator.next(event);
|
|||
|
}
|
|||
|
|
|||
|
window.clear = function*(callback) {
|
|||
|
document.cookie = "c1=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
|||
|
document.cookie = "c3=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
|||
|
document.cookie = "cs2=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
|||
|
|
|||
|
localStorage.clear();
|
|||
|
indexedDB.deleteDatabase("idb1").onsuccess = successClear;
|
|||
|
yield undefined;
|
|||
|
indexedDB.deleteDatabase("idb2").onsuccess = successClear;
|
|||
|
yield undefined;
|
|||
|
|
|||
|
dump("removed cookies, localStorage and indexedDB data from " +
|
|||
|
document.location + "\n");
|
|||
|
callback();
|
|||
|
};
|
|||
|
</script>
|
|||
|
</body>
|
|||
|
</html>
|