tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_storage_indexeddb_delete_blocked.js (1711B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 // Test what happens when deleting indexedDB database is blocked
      8 
      9 add_task(async function () {
     10  await openTabAndSetupStorage(
     11    MAIN_DOMAIN_SECURED + "storage-idb-delete-blocked.html"
     12  );
     13 
     14  info("test state before delete");
     15  await checkState([
     16    [["indexedDB", "https://test1.example.org"], ["idb (default)"]],
     17  ]);
     18 
     19  info("do the delete");
     20  await selectTreeItem(["indexedDB", "https://test1.example.org"]);
     21  const front = gUI.getCurrentFront();
     22  let result = await front.removeDatabase(
     23    "https://test1.example.org",
     24    "idb (default)"
     25  );
     26 
     27  ok(result.blocked, "removeDatabase attempt is blocked");
     28 
     29  info("test state after blocked delete");
     30  await checkState([
     31    [["indexedDB", "https://test1.example.org"], ["idb (default)"]],
     32  ]);
     33 
     34  const eventWait = gUI.once("store-objects-edit");
     35 
     36  info("telling content to close the db");
     37  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
     38    const win = content.wrappedJSObject;
     39    await win.closeDb();
     40  });
     41 
     42  info("waiting for store edit events");
     43  await eventWait;
     44 
     45  info("test state after real delete");
     46  await checkState([[["indexedDB", "https://test1.example.org"], []]]);
     47 
     48  info("try to delete database from nonexistent host");
     49  let errorThrown = false;
     50  try {
     51    result = await front.removeDatabase(
     52      "https://test2.example.org",
     53      "idb (default)"
     54    );
     55  } catch (ex) {
     56    errorThrown = true;
     57  }
     58 
     59  ok(errorThrown, "error was reported when trying to delete");
     60 });