Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add missing service worker content filter check
https://bugs.webkit.org/show_bug.cgi?id=255418 rdar://107453214 Reviewed by Brent Fulgham. This patch was authored by Ben Nham and Per Arne Vollan. Add missing service worker content filter check after finished adding data. This fixes an issue where service workers are incorrectly blocked. * LayoutTests/TestExpectations: * LayoutTests/http/wpt/service-workers/basic-fetch-with-contentfilter-allow-after-adding-data-expected.txt: Added. * LayoutTests/http/wpt/service-workers/basic-fetch-with-contentfilter-allow-after-adding-data.html: Added. * LayoutTests/http/wpt/service-workers/basic-fetch-with-contentfilter.js: (doTest): * LayoutTests/platform/ios/TestExpectations: * LayoutTests/platform/mac/TestExpectations: * Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::serviceWorkerDidFinish): Canonical link: https://commits.webkit.org/262972@main
- Loading branch information
Showing
7 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...p/wpt/service-workers/basic-fetch-with-contentfilter-allow-after-adding-data-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
PASS Setup worker | ||
PASS Fetch with content filter | ||
|
41 changes: 41 additions & 0 deletions
41
...ests/http/wpt/service-workers/basic-fetch-with-contentfilter-allow-after-adding-data.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
var scope = "resources"; | ||
var activeWorker; | ||
|
||
if (window.internals) { | ||
var settings = window.internals.mockContentFilterSettings; | ||
settings.enabled = true; | ||
settings.decisionPoint = "afterFinishedAddingData"; | ||
settings.decision = "allow"; | ||
settings.blockedString = "<!DOCTYPE html><body>PASS"; | ||
} | ||
|
||
promise_test(async (test) => { | ||
var registration = await navigator.serviceWorker.register("basic-fetch-with-contentfilter.js", { scope : scope }); | ||
activeWorker = registration.active; | ||
if (activeWorker) | ||
return; | ||
activeWorker = registration.installing; | ||
return new Promise(resolve => { | ||
activeWorker.addEventListener('statechange', () => { | ||
if (activeWorker.state === "activated") | ||
resolve(); | ||
}); | ||
}); | ||
}, "Setup worker"); | ||
|
||
promise_test(async (test) => { | ||
const iframe = await with_iframe(scope); | ||
|
||
assert_equals(iframe.contentWindow.document.body.innerHTML, "Test"); | ||
}, "Fetch with content filter"); | ||
</script> | ||
</body> | ||
</html> |
2 changes: 1 addition & 1 deletion
2
LayoutTests/http/wpt/service-workers/basic-fetch-with-contentfilter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
function doTest(event) | ||
{ | ||
event.respondWith(new Response('Test', { status: 200, statusText: "Hello from service worker", headers: [["Hello", "World"]] })); | ||
event.respondWith(new Response('<html><body>Test</body></html>', { status: 200, statusText: "Hello from service worker", headers: [["Content-Type", "text/html; charset=utf-8"]] })); | ||
} | ||
|
||
self.addEventListener("fetch", doTest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters