dom/indexedDB/test/webapp_clearBrowserData_browserFrame.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 <!--
     2   Any copyright is dedicated to the Public Domain.
     3   http://creativecommons.org/publicdomain/zero/1.0/
     4 -->
     5 <html>
     6 <head>
     7   <title>Indexed Database Clear Browser Data Test</title>
     9   <script type="text/javascript;version=1.7">
    10     "use strict";
    12     function ok(cond, message)
    13     {
    14       alert(JSON.stringify({ type: "ok",
    15                              args: [!!cond, "browserFrame: " + message] }));
    16     }
    18     function info(message)
    19     {
    20       alert(JSON.stringify({ type: "info",
    21                              args: ["browserFrame: " + message] }));
    22     }
    24     function block()
    25     {
    26       info("about to block");
    28       // This will block until the parent has cleared our database.
    29       alert(JSON.stringify({ type: "block" }));
    31       info("unblocked");
    32     }
    34     function finish()
    35     {
    36       alert(JSON.stringify({ type: "done" }));
    37     }
    39     window.onerror = ok.bind(window, false);
    41     function testSteps()
    42     {
    43       const objectStoreName = "foo";
    44       const testKey = 1;
    45       const testValue = objectStoreName;
    46       const dbName = window.location.pathname + window.location.search;
    48       let request = indexedDB.open(dbName, 1);
    49       request.onerror = errorHandler;
    50       request.onupgradeneeded = grabEventAndContinueHandler;
    51       request.onsuccess = unexpectedSuccessHandler;
    52       let event = yield undefined;
    54       let db = event.target.result;
    55       db.onerror = errorHandler;
    56       db.onversionchange = function(event) {
    57         event.target.close();
    58       }
    60       let objectStore = db.createObjectStore(objectStoreName);
    61       objectStore.add(testValue, testKey);
    63       request.onsuccess = grabEventAndContinueHandler;
    64       event = yield undefined;
    66       ok(db === event.target.result, "created database");
    68       objectStore =
    69         db.transaction(objectStoreName).objectStore(objectStoreName);
    70       objectStore.get(testKey).onsuccess = grabEventAndContinueHandler;
    71       event = yield undefined;
    73       ok(testValue == event.target.result, "data exists");
    75       block();
    77       request = indexedDB.open(dbName, 1);
    78       request.onerror = errorHandler;
    79       request.onupgradeneeded = grabEventAndContinueHandler;
    80       request.onsuccess = unexpectedSuccessHandler;
    81       event = yield undefined;
    83       ok(event.type == "upgradeneeded", "db doesn't exist");
    85       request.onsuccess = grabEventAndContinueHandler;
    86       event = yield undefined;
    88       db = event.target.result;
    89       info(db.objectStoreNames.length);
    90       ok(!db.objectStoreNames.length, "no object stores");
    92       finish();
    94       yield undefined;
    95     }
    97   </script>
    99   <script type="text/javascript;version=1.7" src="helpers.js"></script>
   100 </head>
   102 <body onload="testGenerator.next();"></body>
   104 </html>

mercurial