1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
5 * Ensures resources can still be fetched without validation
9 "http://www.example.com/browser/dom/base/test/file_browser_refresh_content.html";
11 async function run_test_browser_refresh(forceRevalidate) {
12 let tab = await BrowserTestUtils.openNewForegroundTab({
16 /* Ensures each run is started with a fresh state */
17 forceNewProcess: true,
20 let originalAttributes = await SpecialPowers.spawn(
24 let result = content.document.getElementById("result");
25 await ContentTaskUtils.waitForCondition(() => {
27 result.getAttribute("imageDataURL") &&
28 result.getAttribute("iframeContent") &&
29 result.getAttribute("expiredResourceCacheControl")
33 imageDataURL: result.getAttribute("imageDataURL"),
34 iframeContent: result.getAttribute("iframeContent"),
35 expiredResourceCacheControl: result.getAttribute(
36 "expiredResourceCacheControl"
42 let imageDataURL = originalAttributes.imageDataURL;
43 let expiredResourceCacheControl =
44 originalAttributes.expiredResourceCacheControl;
47 originalAttributes.iframeContent,
49 "Iframe is loaded with the initial content"
52 tab.linkedBrowser.reload();
54 await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
56 let attributes = await SpecialPowers.spawn(
60 let result = content.document.getElementById("result");
62 await ContentTaskUtils.waitForCondition(() => {
64 result.getAttribute("imageDataURL") &&
65 result.getAttribute("expiredResourceCacheControl") &&
66 result.getAttribute("nonCacheableResourceCompleted")
71 iframeContent: result.getAttribute("iframeContent"),
72 imageDataURL: result.getAttribute("imageDataURL"),
73 expiredResourceCacheControl: result.getAttribute(
74 "expiredResourceCacheControl"
76 nonCacheableResourceCompleted: result.getAttribute(
77 "nonCacheableResourceCompleted"
84 attributes.iframeContent,
86 "Iframe should always be revalidated"
89 if (!forceRevalidate) {
91 attributes.imageDataURL,
93 "Image should use cache"
96 Assert.notStrictEqual(
97 attributes.imageDataURL,
99 "Image should be revalidated"
103 if (!forceRevalidate) {
105 attributes.expiredResourceCacheControl,
106 expiredResourceCacheControl,
107 "max-age shouldn't be changed after reload because it didn't revalidate"
110 Assert.notStrictEqual(
111 attributes.expiredResourceCacheControl,
112 expiredResourceCacheControl,
113 "max-age should be changed after reload because it got revalidated"
118 attributes.nonCacheableResourceCompleted,
120 "Non cacheable resource should still be loaded"
123 await BrowserTestUtils.removeTab(tab);
126 add_task(async function test_browser_refresh() {
127 Services.prefs.setBoolPref(
128 "browser.soft_reload.only_force_validate_top_level_document",
131 await run_test_browser_refresh(false);
132 Services.prefs.setBoolPref(
133 "browser.soft_reload.only_force_validate_top_level_document",
136 await run_test_browser_refresh(true);