Closed Bug 2024192 Opened 5 months ago Closed 5 months ago

test_ext_webRequest_filterResponseData.js expects the webRequest listener to be called for cached reload

Categories

(WebExtensions :: General, task)

task

Tracking

(firefox150 fixed)

RESOLVED FIXED
150 Branch
Tracking Status
firefox150 --- fixed

People

(Reporter: arai, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

the test_alternate_cached_data testcase in test_ext_webRequest_filterResponseData.js expects the webRequest listener to be called for cached reload.

The test does the following:

  • load a page file_script.html without the extension
  • the page loads scripts file_script_good.js and file_script_bad.js
  • start the extension
  • the extension adds webRequest listeners for file_script_good.js and file_script_bad.js
  • reload the page
  • expect the webRequest listeners to be called

Once the stencil navigation cache (bug 1670403) is enabled, those scripts are cached in memory, and reloading the page doesn't trigger the webRequest listeners.
This cache behavior is clarified in the API document, and there's a dedicate API to clear the cache, which is webRequest.handlerBehaviorChanged.

We should either:

  • if we just apply the restriction here as well, call webRequest.handlerBehaviorChanged in the testcase
  • if we try to support this kind of use case, for maximum compatibility, perform the equivalent of webRequest.handlerBehaviorChanged automatically on an extension startup

https://searchfox.org/firefox-main/rev/804ffad3df416ac8418f3c0df7679a8fe3d718fa/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_filterResponseData.js#660-673

let contentPage = await ExtensionTestUtils.loadContentPage(
  "http://example.com/data/file_script.html"
);
await contentPage.close();

await extension.startup();

let page_cached = await ExtensionTestUtils.loadContentPage(
  "http://example.com/data/file_script.html"
);
await Promise.all([
  extension.awaitMessage("onBeforeRequest"),
  extension.awaitMessage("onHeadersReceived"),
]);

https://searchfox.org/firefox-main/rev/804ffad3df416ac8418f3c0df7679a8fe3d718fa/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_filterResponseData.js#583-584,611-612,651-652

background() {
  browser.webRequest.onBeforeRequest.addListener(
...
  );
  browser.webRequest.onHeadersReceived.addListener(
...
  );
},
Attachment #9554232 - Attachment description: Bug 2024192 - Clear the cache in the webRequest testcase. r?#extension-reviewers! → Bug 2024192 - Part 1: Clear the cache in the webRequest testcase. r?#extension-reviewers!
Blocks: stencil-nav
See Also: → 2024620
Pushed by arai_a@mac.com: https://github.com/mozilla-firefox/firefox/commit/3769b96df5fa https://hg.mozilla.org/integration/autoland/rev/37f69337143d Part 1: Clear the cache in the webRequest testcase. r=extension-reviewers,robwu https://github.com/mozilla-firefox/firefox/commit/afa1ab3d002a https://hg.mozilla.org/integration/autoland/rev/86d030b73a04 Part 2: Add test ors for webRequest and script disk/memory cache. r=extension-reviewers,robwu
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
Regressions: 2024927
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: