dom/datastore/tests/file_duplicate.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <meta charset="utf-8">
     5   <title>Test for DataStore - duplicate keys</title>
     6 </head>
     7 <body>
     8 <div id="container"></div>
     9   <script type="application/javascript;version=1.7">
    11   var gStore;
    12   var gEvent;
    13   var gChangeId;
    15   function ok(a, msg) {
    16     alert((a ? 'OK' : 'KO')+ ' ' + msg)
    17   }
    19   function is(a, b, msg) {
    20     ok(a === b, msg);
    21   }
    23   function cbError() {
    24     alert('KO error');
    25   }
    27   function finish() {
    28     alert('DONE');
    29   }
    31   function testGetDataStores() {
    32     navigator.getDataStores('foo').then(function(stores) {
    33       gStore = stores[0];
    34       runTest();
    35     }, cbError);
    36   }
    38   function testAdd(success) {
    39     gStore.add({ a: 42 }, 'test').then(function() {
    40       is(success, true, "Record added");
    41       runTest();
    42     }, function(e) {
    43       is(success, false, "Record failed");
    44       ok(e instanceof DOMError, "DOMError received");
    45       is(e.name, 'ConstraintError', 'e.name: ConstraintError');
    46       is(e.message, '', 'e.message');
    47       runTest();
    48     });
    49   }
    51   var tests = [
    52     // Test for GetDataStore
    53     testGetDataStores,
    55     // add
    56     function() { testAdd(true); },
    58     // add duplicate
    59     function() { testAdd(false); }
    60   ];
    62   function runTest() {
    63     if (!tests.length) {
    64       finish();
    65       return;
    66     }
    68     var test = tests.shift();
    69     test();
    70   }
    72   runTest();
    73   </script>
    74 </body>
    75 </html>

mercurial