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 | <html> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Indexed Database Property Test</title> |
michael@0 | 8 | |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | |
michael@0 | 12 | <script type="text/javascript;version=1.7"> |
michael@0 | 13 | function testSteps() |
michael@0 | 14 | { |
michael@0 | 15 | const READ_WRITE = "readwrite"; |
michael@0 | 16 | |
michael@0 | 17 | const name = window.location.pathname; |
michael@0 | 18 | |
michael@0 | 19 | const objectStoreName = "Blobs"; |
michael@0 | 20 | |
michael@0 | 21 | const fileData = { key: 1, file: getRandomFile("random.bin", 100000) }; |
michael@0 | 22 | |
michael@0 | 23 | { |
michael@0 | 24 | let request = indexedDB.open(name, 1); |
michael@0 | 25 | request.onerror = errorHandler; |
michael@0 | 26 | request.onupgradeneeded = grabEventAndContinueHandler; |
michael@0 | 27 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 28 | let event = yield undefined; |
michael@0 | 29 | |
michael@0 | 30 | is(event.type, "upgradeneeded", "Got correct event type"); |
michael@0 | 31 | |
michael@0 | 32 | let db = event.target.result; |
michael@0 | 33 | db.onerror = errorHandler; |
michael@0 | 34 | |
michael@0 | 35 | let objectStore = db.createObjectStore(objectStoreName, { }); |
michael@0 | 36 | |
michael@0 | 37 | objectStore.add(fileData.file, fileData.key); |
michael@0 | 38 | |
michael@0 | 39 | event = yield undefined; |
michael@0 | 40 | |
michael@0 | 41 | is(event.type, "success", "Got correct event type"); |
michael@0 | 42 | |
michael@0 | 43 | let trans = db.transaction([objectStoreName], READ_WRITE); |
michael@0 | 44 | objectStore = trans.objectStore(objectStoreName); |
michael@0 | 45 | |
michael@0 | 46 | objectStore.delete(fileData.key); |
michael@0 | 47 | |
michael@0 | 48 | trans.oncomplete = grabEventAndContinueHandler; |
michael@0 | 49 | event = yield undefined; |
michael@0 | 50 | |
michael@0 | 51 | is(getFileDBRefCount(name, 1), 0, "Correct db ref count"); |
michael@0 | 52 | |
michael@0 | 53 | trans = db.transaction([objectStoreName], READ_WRITE); |
michael@0 | 54 | objectStore = trans.objectStore(objectStoreName); |
michael@0 | 55 | |
michael@0 | 56 | request = objectStore.add(fileData.file, fileData.key); |
michael@0 | 57 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 58 | event = yield undefined; |
michael@0 | 59 | |
michael@0 | 60 | trans.oncomplete = grabEventAndContinueHandler; |
michael@0 | 61 | event = yield undefined; |
michael@0 | 62 | |
michael@0 | 63 | is(getFileDBRefCount(name, 1), 1, "Correct db ref count"); |
michael@0 | 64 | |
michael@0 | 65 | fileData.file = null; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | scheduleGC(); |
michael@0 | 69 | yield undefined; |
michael@0 | 70 | |
michael@0 | 71 | is(getFileRefCount(name, 1), 0, "Correct ref count"); |
michael@0 | 72 | |
michael@0 | 73 | { |
michael@0 | 74 | let request = indexedDB.open(name, 1); |
michael@0 | 75 | request.onerror = errorHandler; |
michael@0 | 76 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 77 | let event = yield undefined; |
michael@0 | 78 | |
michael@0 | 79 | is(event.type, "success", "Got correct event type"); |
michael@0 | 80 | |
michael@0 | 81 | let db = event.target.result; |
michael@0 | 82 | db.onerror = errorHandler; |
michael@0 | 83 | |
michael@0 | 84 | let trans = db.transaction([objectStoreName], READ_WRITE); |
michael@0 | 85 | objectStore = trans.objectStore(objectStoreName); |
michael@0 | 86 | |
michael@0 | 87 | request = objectStore.get(fileData.key); |
michael@0 | 88 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 89 | event = yield undefined; |
michael@0 | 90 | |
michael@0 | 91 | let result = event.target.result; |
michael@0 | 92 | ok(result, "Got result"); |
michael@0 | 93 | |
michael@0 | 94 | objectStore.delete(fileData.key); |
michael@0 | 95 | |
michael@0 | 96 | trans.oncomplete = grabEventAndContinueHandler; |
michael@0 | 97 | event = yield undefined; |
michael@0 | 98 | |
michael@0 | 99 | is(getFileDBRefCount(name, 1), 0, "Correct db ref count"); |
michael@0 | 100 | |
michael@0 | 101 | trans = db.transaction([objectStoreName], READ_WRITE); |
michael@0 | 102 | objectStore = trans.objectStore(objectStoreName); |
michael@0 | 103 | |
michael@0 | 104 | request = objectStore.add(result, fileData.key); |
michael@0 | 105 | request.onsuccess = grabEventAndContinueHandler; |
michael@0 | 106 | event = yield undefined; |
michael@0 | 107 | |
michael@0 | 108 | trans.oncomplete = grabEventAndContinueHandler; |
michael@0 | 109 | event = yield undefined; |
michael@0 | 110 | |
michael@0 | 111 | is(getFileDBRefCount(name, 1), 1, "Correct db ref count"); |
michael@0 | 112 | |
michael@0 | 113 | event = null; |
michael@0 | 114 | result = null; |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | scheduleGC(); |
michael@0 | 118 | yield undefined; |
michael@0 | 119 | |
michael@0 | 120 | is(getFileRefCount(name, 1), 0, "Correct ref count"); |
michael@0 | 121 | |
michael@0 | 122 | finishTest(); |
michael@0 | 123 | yield undefined; |
michael@0 | 124 | } |
michael@0 | 125 | </script> |
michael@0 | 126 | <script type="text/javascript;version=1.7" src="file.js"></script> |
michael@0 | 127 | <script type="text/javascript;version=1.7" src="helpers.js"></script> |
michael@0 | 128 | |
michael@0 | 129 | </head> |
michael@0 | 130 | |
michael@0 | 131 | <body onload="runTest();"></body> |
michael@0 | 132 | |
michael@0 | 133 | </html> |