Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 var testGenerator = testSteps();
8 function testSteps()
9 {
10 const name = this.window ? window.location.pathname : "Splendid Test";
11 const objectStoreInfo = [
12 { name: "a", options: { keyPath: "id", autoIncrement: true } },
13 { name: "b", options: { keyPath: "id", autoIncrement: false } },
14 ];
15 const indexInfo = [
16 { name: "1", keyPath: "unique_value", options: { unique: true } },
17 { name: "2", keyPath: "value", options: { unique: false } },
18 { name: "3", keyPath: "value", options: { unique: false } },
19 { name: "", keyPath: "value", options: { unique: false } },
20 { name: null, keyPath: "value", options: { unique: false } },
21 { name: undefined, keyPath: "value", options: { unique: false } },
22 ];
24 let request = indexedDB.open(name, 1);
25 request.onerror = errorHandler;
26 request.onupgradeneeded = grabEventAndContinueHandler;
27 request.onsuccess = unexpectedSuccessHandler;
28 let event = yield undefined;
29 let db = event.target.result;
31 for (let i = 0; i < objectStoreInfo.length; i++) {
32 let info = objectStoreInfo[i];
33 let objectStore = info.hasOwnProperty("options") ?
34 db.createObjectStore(info.name, info.options) :
35 db.createObjectStore(info.name);
37 try {
38 request = objectStore.createIndex("Hola");
39 ok(false, "createIndex with no keyPath should throw");
40 }
41 catch(e) {
42 ok(true, "createIndex with no keyPath should throw");
43 }
45 let ex;
46 try {
47 objectStore.createIndex("Hola", ["foo"], { multiEntry: true });
48 }
49 catch(e) {
50 ex = e;
51 }
52 ok(ex, "createIndex with array keyPath and multiEntry should throw");
53 is(ex.name, "InvalidAccessError", "should throw right exception");
54 ok(ex instanceof DOMException, "should throw right exception");
55 is(ex.code, DOMException.INVALID_ACCESS_ERR, "should throw right exception");
57 try {
58 objectStore.createIndex("foo", "bar", 10);
59 ok(false, "createIndex with bad options should throw");
60 }
61 catch(e) {
62 ok(true, "createIndex with bad options threw");
63 }
65 ok(objectStore.createIndex("foo", "bar", { foo: "" }),
66 "createIndex with unknown options should not throw");
67 objectStore.deleteIndex("foo");
69 // Test index creation, and that it ends up in indexNames.
70 let objectStoreName = info.name;
71 for (let j = 0; j < indexInfo.length; j++) {
72 let info = indexInfo[j];
73 let count = objectStore.indexNames.length;
74 let index = info.hasOwnProperty("options") ?
75 objectStore.createIndex(info.name, info.keyPath,
76 info.options) :
77 objectStore.createIndex(info.name, info.keyPath);
79 let name = info.name;
80 if (name === null) {
81 name = "null";
82 }
83 else if (name === undefined) {
84 name = "undefined";
85 }
87 is(index.name, name, "correct name");
88 is(index.keyPath, info.keyPath, "correct keyPath");
89 is(index.unique, info.options.unique, "correct uniqueness");
91 is(objectStore.indexNames.length, count + 1,
92 "indexNames grew in size");
93 let found = false;
94 for (let k = 0; k < objectStore.indexNames.length; k++) {
95 if (objectStore.indexNames.item(k) == name) {
96 found = true;
97 break;
98 }
99 }
100 ok(found, "Name is on objectStore.indexNames");
102 ok(event.target.transaction, "event has a transaction");
103 ok(event.target.transaction.db === db,
104 "transaction has the right db");
105 is(event.target.transaction.mode, "versionchange",
106 "transaction has the correct mode");
107 is(event.target.transaction.objectStoreNames.length, i + 1,
108 "transaction only has one object store");
109 ok(event.target.transaction.objectStoreNames.contains(objectStoreName),
110 "transaction has the correct object store");
111 }
112 }
114 request.onsuccess = grabEventAndContinueHandler;
115 request.onupgradeneeded = unexpectedSuccessHandler;
117 event = yield undefined;
119 finishTest();
120 yield undefined;
121 }