summaryrefslogtreecommitdiffstats
path: root/devtools/client/storage/test/browser_storage_fission_local_storage.js
blob: ae495160315091b7da18c9589afee731a088cb73 (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
36
37
38
39
40
41
42
43
44
45
/* 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";

add_task(async function () {
  const URL_IFRAME = buildURLWithContent(
    "example.net",
    `<h1>iframe</h1>` +
      `<script>localStorage.setItem("lorem", "ipsum");</script>`
  );
  const URL_MAIN = buildURLWithContent(
    "example.com",
    `<h1>Main</h1>` +
      `<script>localStorage.setItem("foo", "bar");</script>` +
      `<iframe src="${URL_IFRAME}">`
  );

  // open tab
  await openTabAndSetupStorage(URL_MAIN);
  const doc = gPanelWindow.document;

  // check that both hosts appear in the storage tree
  checkTree(doc, ["localStorage", "https://example.com"]);
  // check the table for values
  await selectTreeItem(["localStorage", "https://example.com"]);
  await waitForStorageData("foo", "bar");
  await selectTreeItem(["localStorage", "https://example.net"]);
  await waitForStorageData("lorem", "ipsum");

  // add more storage data to the main wrapper
  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
    content.window.localStorage.setItem("foo2", "bar2");
    const iframe = content.document.querySelector("iframe");
    return SpecialPowers.spawn(iframe, [], () => {
      content.window.localStorage.setItem("lorem2", "ipsum2");
    });
  });
  // check that the new data is shown in the table
  await selectTreeItem(["localStorage", "https://example.com"]);
  await waitForStorageData("foo2", "bar2");
  await selectTreeItem(["localStorage", "https://example.net"]);
  await waitForStorageData("lorem2", "ipsum2");
});