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.
michael@0 | 1 | /** |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | var testGenerator = testSteps(); |
michael@0 | 7 | |
michael@0 | 8 | function testSteps() |
michael@0 | 9 | { |
michael@0 | 10 | const name = this.window ? window.location.pathname : "Splendid Test"; |
michael@0 | 11 | const objectStoreName = "Objects"; |
michael@0 | 12 | |
michael@0 | 13 | let request = indexedDB.open(name, 1); |
michael@0 | 14 | request.onerror = errorHandler; |
michael@0 | 15 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 16 | let event = yield undefined; |
michael@0 | 17 | |
michael@0 | 18 | let db = event.target.result; |
michael@0 | 19 | is(db.objectStoreNames.length, 0, "Correct objectStoreNames list"); |
michael@0 | 20 | |
michael@0 | 21 | let objectStore = db.createObjectStore(objectStoreName, |
michael@0 | 22 | { keyPath: "foo" }); |
michael@0 | 23 | |
michael@0 | 24 | let addedCount = 0; |
michael@0 | 25 | |
michael@0 | 26 | for (let i = 0; i < 100; i++) { |
michael@0 | 27 | request = objectStore.add({foo: i}); |
michael@0 | 28 | request.onerror = errorHandler; |
michael@0 | 29 | request.onsuccess = function(event) { |
michael@0 | 30 | if (++addedCount == 100) { |
michael@0 | 31 | executeSoon(function() { testGenerator.next(); }); |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | yield undefined; |
michael@0 | 36 | |
michael@0 | 37 | is(db.objectStoreNames.length, 1, "Correct objectStoreNames list"); |
michael@0 | 38 | is(db.objectStoreNames.item(0), objectStoreName, "Correct name"); |
michael@0 | 39 | |
michael@0 | 40 | db.close(); |
michael@0 | 41 | |
michael@0 | 42 | let request = indexedDB.open(name, 2); |
michael@0 | 43 | request.onerror = errorHandler; |
michael@0 | 44 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 45 | let event = yield undefined; |
michael@0 | 46 | |
michael@0 | 47 | let db = event.target.result; |
michael@0 | 48 | let trans = event.target.transaction; |
michael@0 | 49 | |
michael@0 | 50 | let oldObjectStore = trans.objectStore(objectStoreName); |
michael@0 | 51 | isnot(oldObjectStore, null, "Correct object store prior to deleting"); |
michael@0 | 52 | db.deleteObjectStore(objectStoreName); |
michael@0 | 53 | is(db.objectStoreNames.length, 0, "Correct objectStores list"); |
michael@0 | 54 | try { |
michael@0 | 55 | trans.objectStore(objectStoreName); |
michael@0 | 56 | ok(false, "should have thrown"); |
michael@0 | 57 | } |
michael@0 | 58 | catch(ex) { |
michael@0 | 59 | ok(ex instanceof DOMException, "Got a DOMException"); |
michael@0 | 60 | is(ex.name, "NotFoundError", "expect a NotFoundError"); |
michael@0 | 61 | is(ex.code, DOMException.NOT_FOUND_ERR, "expect a NOT_FOUND_ERR"); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | objectStore = db.createObjectStore(objectStoreName, { keyPath: "foo" }); |
michael@0 | 65 | is(db.objectStoreNames.length, 1, "Correct objectStoreNames list"); |
michael@0 | 66 | is(db.objectStoreNames.item(0), objectStoreName, "Correct name"); |
michael@0 | 67 | is(trans.objectStore(objectStoreName), objectStore, "Correct new objectStore"); |
michael@0 | 68 | isnot(oldObjectStore, objectStore, "Old objectStore is not new objectStore"); |
michael@0 | 69 | |
michael@0 | 70 | request = objectStore.openCursor(); |
michael@0 | 71 | request.onerror = errorHandler; |
michael@0 | 72 | request.onsuccess = function(event) { |
michael@0 | 73 | is(event.target.result, undefined, "ObjectStore shouldn't have any items"); |
michael@0 | 74 | testGenerator.send(event); |
michael@0 | 75 | } |
michael@0 | 76 | event = yield undefined; |
michael@0 | 77 | |
michael@0 | 78 | db.deleteObjectStore(objectStore.name); |
michael@0 | 79 | is(db.objectStoreNames.length, 0, "Correct objectStores list"); |
michael@0 | 80 | |
michael@0 | 81 | continueToNextStep(); |
michael@0 | 82 | yield undefined; |
michael@0 | 83 | |
michael@0 | 84 | db.close(); |
michael@0 | 85 | |
michael@0 | 86 | let request = indexedDB.open(name, 3); |
michael@0 | 87 | request.onerror = errorHandler; |
michael@0 | 88 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 89 | let event = yield undefined; |
michael@0 | 90 | |
michael@0 | 91 | let db = event.target.result; |
michael@0 | 92 | |
michael@0 | 93 | objectStore = db.createObjectStore(objectStoreName, { keyPath: "foo" }); |
michael@0 | 94 | |
michael@0 | 95 | request = objectStore.add({foo:"bar"}); |
michael@0 | 96 | request.onerror = errorHandler; |
michael@0 | 97 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 98 | |
michael@0 | 99 | db.deleteObjectStore(objectStoreName); |
michael@0 | 100 | |
michael@0 | 101 | event = yield undefined; |
michael@0 | 102 | |
michael@0 | 103 | finishTest(); |
michael@0 | 104 | yield undefined; |
michael@0 | 105 | } |