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 | <!DOCTYPE HTML> |
michael@0 | 6 | <html> <!-- |
michael@0 | 7 | https://bugzilla.mozilla.org/show_bug.cgi?id=910412 |
michael@0 | 8 | --> |
michael@0 | 9 | <head> |
michael@0 | 10 | <title>Test createDirectory of the FileSystem API for device storage</title> |
michael@0 | 11 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | <script type="text/javascript" src="devicestorage_common.js"></script> |
michael@0 | 13 | |
michael@0 | 14 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 15 | </head> |
michael@0 | 16 | <body> |
michael@0 | 17 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=910412">Mozilla Bug 910412</a> |
michael@0 | 18 | <p id="display"></p> |
michael@0 | 19 | <div id="content" style="display: none"> |
michael@0 | 20 | </div> |
michael@0 | 21 | <pre id="test"> |
michael@0 | 22 | <script class="testbody" type="text/javascript"> |
michael@0 | 23 | |
michael@0 | 24 | devicestorage_setup(); |
michael@0 | 25 | |
michael@0 | 26 | // The root directory object. |
michael@0 | 27 | var gRoot; |
michael@0 | 28 | var gTestCount = 0; |
michael@0 | 29 | var gPath = ''; |
michael@0 | 30 | var gName = ''; |
michael@0 | 31 | |
michael@0 | 32 | function testCreateDirectory(rootDir, path) { |
michael@0 | 33 | rootDir.createDirectory(path).then(createDirectorySuccess, cbError); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function createDirectorySuccess(d) { |
michael@0 | 37 | ok(d.name === gName, "Failed to create directory: name mismatch."); |
michael@0 | 38 | |
michael@0 | 39 | // Get the new created directory from the root. |
michael@0 | 40 | gRoot.get(gPath).then(getSuccess, cbError); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function getSuccess(d) { |
michael@0 | 44 | ok(d.name === gName, "Should get directory - " + (gPath || "[root]") + "."); |
michael@0 | 45 | switch (gTestCount) { |
michael@0 | 46 | case 0: |
michael@0 | 47 | gRoot = d; |
michael@0 | 48 | // Create a new directory under the root. |
michael@0 | 49 | gName = gPath = randomFilename(12); |
michael@0 | 50 | testCreateDirectory(gRoot, gName); |
michael@0 | 51 | break; |
michael@0 | 52 | case 1: |
michael@0 | 53 | // Create a sub-directory under current directory. |
michael@0 | 54 | gName = randomFilename(12); |
michael@0 | 55 | gPath = gPath + '/' + gName; |
michael@0 | 56 | testCreateDirectory(d, gName); |
michael@0 | 57 | break; |
michael@0 | 58 | case 2: |
michael@0 | 59 | // Create directory with an existing path. |
michael@0 | 60 | gRoot.createDirectory(gPath).then(function(what) { |
michael@0 | 61 | ok(false, "Should not overwrite an existing directory."); |
michael@0 | 62 | devicestorage_cleanup(); |
michael@0 | 63 | }, function(e) { |
michael@0 | 64 | ok(true, "Creating directory should fail if it already exists."); |
michael@0 | 65 | |
michael@0 | 66 | // Create a directory whose intermediate directory doesn't exit. |
michael@0 | 67 | gName = randomFilename(12); |
michael@0 | 68 | gPath = 'sub1/sub2/' + gName; |
michael@0 | 69 | testCreateDirectory(gRoot, gPath); |
michael@0 | 70 | }); |
michael@0 | 71 | break; |
michael@0 | 72 | default: |
michael@0 | 73 | // Create the parent directory. |
michael@0 | 74 | d.createDirectory('..').then(function(what) { |
michael@0 | 75 | ok(false, "Should not overwrite an existing directory."); |
michael@0 | 76 | devicestorage_cleanup(); |
michael@0 | 77 | }, function(e) { |
michael@0 | 78 | ok(true, "Accessing parent directory with '..' is not allowed."); |
michael@0 | 79 | devicestorage_cleanup(); |
michael@0 | 80 | }); |
michael@0 | 81 | break; |
michael@0 | 82 | } |
michael@0 | 83 | gTestCount++; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function cbError(e) { |
michael@0 | 87 | ok(false, e.name + " error should not arrive here!"); |
michael@0 | 88 | devicestorage_cleanup(); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | ok(navigator.getDeviceStorage, "Should have getDeviceStorage."); |
michael@0 | 92 | |
michael@0 | 93 | var storage = navigator.getDeviceStorage("pictures"); |
michael@0 | 94 | ok(storage, "Should have gotten a storage."); |
michael@0 | 95 | |
michael@0 | 96 | var promise = storage.getRoot(); |
michael@0 | 97 | ok(promise, "Should have a non-null promise for getRoot."); |
michael@0 | 98 | |
michael@0 | 99 | gName = storage.storageName; |
michael@0 | 100 | promise.then(getSuccess, cbError); |
michael@0 | 101 | </script> |
michael@0 | 102 | </pre> |
michael@0 | 103 | </body> |
michael@0 | 104 | </html> |
michael@0 | 105 |