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 data = { id: new Date().getTime(), |
michael@0 | 11 | num: parseInt(Math.random() * 1000) }; |
michael@0 | 12 | |
michael@0 | 13 | let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 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 | db.onerror = errorHandler; |
michael@0 | 20 | |
michael@0 | 21 | event.target.onsuccess = continueToNextStep; |
michael@0 | 22 | |
michael@0 | 23 | // Make object store, add data. |
michael@0 | 24 | let objectStore = db.createObjectStore("foo", { keyPath: "id" }); |
michael@0 | 25 | objectStore.add(data); |
michael@0 | 26 | yield undefined; |
michael@0 | 27 | db.close(); |
michael@0 | 28 | |
michael@0 | 29 | let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 2); |
michael@0 | 30 | request.onerror = errorHandler; |
michael@0 | 31 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 32 | let event = yield undefined; |
michael@0 | 33 | |
michael@0 | 34 | let db2 = event.target.result; |
michael@0 | 35 | db2.onerror = errorHandler; |
michael@0 | 36 | |
michael@0 | 37 | event.target.onsuccess = continueToNextStep; |
michael@0 | 38 | |
michael@0 | 39 | // Create index. |
michael@0 | 40 | event.target.transaction.objectStore("foo").createIndex("foo", "num"); |
michael@0 | 41 | yield undefined; |
michael@0 | 42 | |
michael@0 | 43 | // Make sure our object made it into the index. |
michael@0 | 44 | let seenCount = 0; |
michael@0 | 45 | |
michael@0 | 46 | |
michael@0 | 47 | db2.transaction("foo").objectStore("foo").index("foo") |
michael@0 | 48 | .openKeyCursor().onsuccess = function(event) { |
michael@0 | 49 | let cursor = event.target.result; |
michael@0 | 50 | if (cursor) { |
michael@0 | 51 | is(cursor.key, data.num, "Good key"); |
michael@0 | 52 | is(cursor.primaryKey, data.id, "Good value"); |
michael@0 | 53 | seenCount++; |
michael@0 | 54 | cursor.continue(); |
michael@0 | 55 | } |
michael@0 | 56 | else { |
michael@0 | 57 | continueToNextStep(); |
michael@0 | 58 | } |
michael@0 | 59 | }; |
michael@0 | 60 | yield undefined; |
michael@0 | 61 | |
michael@0 | 62 | is(seenCount, 1, "Saw our entry"); |
michael@0 | 63 | |
michael@0 | 64 | finishTest(); |
michael@0 | 65 | yield undefined; |
michael@0 | 66 | } |