summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/browser/abouthomecache/browser_no_cache_on_SessionStartup_restore.js
blob: a312b2b44fa5dc6eb2d1309ceae56be829a1ab54 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests that if somehow about:newtab loads before about:home does, that we
 * don't use the cache. This is because about:newtab doesn't use the cache,
 * and so it'll inevitably be newer than what's in the about:home cache,
 * which will put the about:home cache out of date the next time about:home
 * eventually loads.
 */
add_task(async function test_no_cache_on_SessionStartup_restore() {
  await withFullyLoadedAboutHome(async browser => {
    await simulateRestart(browser, { skipAboutHomeLoad: true });

    // We remove the preloaded browser to ensure that loading the next
    // about:newtab occurs now, and not at preloading time.
    NewTabPagePreloading.removePreloadedBrowser(window);
    let tab = await BrowserTestUtils.openNewForegroundTab(
      gBrowser,
      "about:newtab"
    );

    let newWin = await BrowserTestUtils.openNewBrowserWindow();

    // The cache is disqualified because about:newtab was loaded first.
    // So now it's too late to use the cache.
    await ensureDynamicAboutHome(
      newWin.gBrowser.selectedBrowser,
      AboutHomeStartupCache.CACHE_RESULT_SCALARS.LATE
    );

    await BrowserTestUtils.closeWindow(newWin);
    await BrowserTestUtils.removeTab(tab);
  });
});