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 -->
5 <!DOCTYPE HTML>
6 <html> <!--
7 https://bugzilla.mozilla.org/show_bug.cgi?id=823965
8 -->
9 <head>
10 <title>Test for the device storage API </title>
11 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
12 <script type="text/javascript" src="devicestorage_common.js"></script>
14 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
15 </head>
16 <body>
17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=823965">Mozilla Bug 823965</a>
18 <p id="display"></p>
19 <div id="content" style="display: none">
21 </div>
22 <pre id="test">
23 <script class="testbody" type="text/javascript">
25 devicestorage_setup();
27 var gFileName = "devicestorage/" + randomFilename(12) + "/hi.png";
28 var gData = "My name is Doug Turner (?!?). My IRC nick is DougT. I like Maple cookies."
29 var gDataBlob = new Blob([gData], {type: 'image/png'});
31 function getSuccess(e) {
32 var storage = navigator.getDeviceStorage("pictures");
33 ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
35 ok(e.target.result.name == gFileName, "File name should match");
36 ok(e.target.result.size > 0, "File size be greater than zero");
37 ok(e.target.result.type, "File should have a mime type");
38 ok(e.target.result.lastModifiedDate, "File should have a last modified date");
40 var mreq = storage.enumerate();
41 mreq.onsuccess = function() {
42 var storage2 = navigator.getDeviceStorage('music');
43 var dreq = storage2.delete(mreq.result.name);
44 dreq.onerror = function () {
45 ok(true, "The bug has been fixed");
46 devicestorage_cleanup();
47 };
48 dreq.onsuccess = function () {
49 ok(false, "The bug has been fixed");
50 devicestorage_cleanup();
51 };
52 };
54 mreq.onerror = getError;
55 }
57 function getError(e) {
58 ok(false, "getError was called : " + e.target.error.name);
59 devicestorage_cleanup();
60 }
62 function addSuccess(e) {
64 var filename = e.target.result;
65 if (filename[0] == "/") {
66 // We got /storageName/prefix/filename
67 // Remove the storageName (this shows up on FirefoxOS)
68 filename = filename.substring(1); // Remove leading slash
69 var slashIndex = filename.indexOf("/");
70 if (slashIndex >= 0) {
71 filename = filename.substring(slashIndex + 1); // Remove storageName
72 }
73 }
74 ok(filename == gFileName, "File name should match");
75 // Since we now have the fully qualified name, change gFileName to that.
76 gFileName = e.target.result;
78 var storage = navigator.getDeviceStorage("pictures");
79 request = storage.get(gFileName);
80 request.onsuccess = getSuccess;
81 request.onerror = getError;
83 ok(true, "addSuccess was called");
84 }
86 function addError(e) {
87 ok(false, "addError was called : " + e.target.error.name);
88 devicestorage_cleanup();
89 }
91 ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
93 var storage = navigator.getDeviceStorage("pictures");
94 ok(storage, "Should have gotten a storage");
96 request = storage.addNamed(gDataBlob, gFileName);
97 ok(request, "Should have a non-null request");
99 request.onsuccess = addSuccess;
100 request.onerror = addError;
102 </script>
103 </pre>
104 </body>
105 </html>