summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_duplicate_history.js
blob: 9e9a386e3bcf449ed057f0c2be6e67433694e27b (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
ChromeUtils.defineESModuleGetters(this, {
  SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
  TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs",
});

add_task(async function() {
  await BrowserTestUtils.withNewTab("http://example.com", async function(
    aBrowser
  ) {
    let tab = gBrowser.getTabForBrowser(aBrowser);
    await TabStateFlusher.flush(aBrowser);
    let before = TabStateCache.get(aBrowser.permanentKey);

    let newTab = SessionStore.duplicateTab(window, tab);
    await Promise.all([
      BrowserTestUtils.browserLoaded(newTab.linkedBrowser),
      TestUtils.topicObserved("sessionstore-debug-tab-restored"),
    ]);
    let after = TabStateCache.get(newTab.linkedBrowser.permanentKey);

    isnot(
      before.history.entries,
      after.history.entries,
      "The entry objects should not be shared"
    );

    BrowserTestUtils.removeTab(newTab);
  });
});