Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'win' && socketprocess_networking && fission OR os == 'android' && debug
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell-remote.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
"use strict";
const { ExtensionStorageIDB } = ChromeUtils.importESModule(
  "resource://gre/modules/ExtensionStorageIDB.sys.mjs"
);
PromiseTestUtils.allowMatchingRejectionsGlobally(
  /WebExtension context not found/
);
const server = createHttpServer({ hosts: ["example.com"] });
server.registerDirectory("/data/", do_get_file("data"));
// The storage API in content scripts should behave identical to the storage API
// in background pages.
AddonTestUtils.init(this);
add_task(async function setup() {
  await ExtensionTestUtils.startAddonManager();
});
add_task(async function test_contentscript_storage_local_file_backend() {
  return runWithPrefs([[ExtensionStorageIDB.BACKEND_ENABLED_PREF, false]], () =>
    test_contentscript_storage("local")
  );
});
add_task(async function test_contentscript_storage_local_idb_backend() {
  return runWithPrefs([[ExtensionStorageIDB.BACKEND_ENABLED_PREF, true]], () =>
    test_contentscript_storage("local")
  );
});
add_task(async function test_contentscript_storage_local_file_getBytesInUse() {
  return runWithPrefs([[ExtensionStorageIDB.BACKEND_ENABLED_PREF, false]], () =>
    test_contentscript_storage_area_getBytesInUse("local")
  );
});
add_task(async function test_contentscript_storage_local_idb_getBytesInUse() {
  return runWithPrefs([[ExtensionStorageIDB.BACKEND_ENABLED_PREF, true]], () =>
    test_contentscript_storage_area_getBytesInUse("local")
  );
});