summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage/test/browser_storage_cache_error.js
blob: 4aef96d0a808b7ccb827cecae43d4191a7670a5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

// Test handling errors in CacheStorage

add_task(async function () {
  // Open the URL in a private browsing window.
  const win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
  const tab = win.gBrowser.selectedBrowser;
  const triggeringPrincipal =
    Services.scriptSecurityManager.getSystemPrincipal();
  tab.loadURI(
    Services.io.newURI(ALT_DOMAIN_SECURED + "storage-cache-error.html"),
    { triggeringPrincipal }
  );
  await BrowserTestUtils.browserLoaded(tab);

  // On enumerating cache storages, CacheStorage::Keys would throw a
  // DOM security exception. We'd like to verify storage panel still work in
  // this case.
  await openStoragePanel({ tab: win.gBrowser.selectedTab });

  const cacheItemId = ["Cache", "https://test2.example.org"];

  await selectTreeItem(cacheItemId);
  ok(
    gUI.tree.isSelected(cacheItemId),
    `The item ${cacheItemId.join(" > ")} is present in the tree`
  );

  await BrowserTestUtils.closeWindow(win);
});