Commit 045b8f9d authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Use OriginalURLViaServiceWorker() for classic worker scripts

This CL changes worker global scope's URL if the request of
the worker top-level script is intercepted by ServiceWorker and
Response with a different URL is supplied to respondWith().

Test: external/wpt/service-workers/service-worker/worker-interception-redirect.https.html
Bug: 861564
Change-Id: I4b91777abd6fa42583ae853330ee2c7bbccf61cb
Reviewed-on: https://chromium-review.googlesource.com/1153598Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584003}
parent 64e4face
...@@ -2,7 +2,7 @@ This is a testharness.js-based test. ...@@ -2,7 +2,7 @@ This is a testharness.js-based test.
PASS initialize global state PASS initialize global state
FAIL request to sw1 scope gets network redirect to sw2 scope assert_equals: expected "the shared worker script was served from network" but got "sw2 saw the request for the worker script" FAIL request to sw1 scope gets network redirect to sw2 scope assert_equals: expected "the shared worker script was served from network" but got "sw2 saw the request for the worker script"
FAIL request to sw1 scope gets network redirect to out-of-scope assert_equals: expected "sw1 saw importScripts from the worker" but got "importScripts: served from network" FAIL request to sw1 scope gets network redirect to out-of-scope assert_equals: expected "sw1 saw importScripts from the worker" but got "importScripts: served from network"
FAIL request to sw1 scope gets service-worker redirect to sw2 scope assert_equals: location.href expected "https://web-platform.test:8444/service-workers/service-worker/resources/worker_interception_redirect_webworker.py?greeting=sw2%20saw%20the%20request%20for%20the%20worker%20script" but got "https://web-platform.test:8444/service-workers/service-worker/resources/scope2/worker_interception_redirect_webworker.py" PASS request to sw1 scope gets service-worker redirect to sw2 scope
FAIL request to sw1 scope gets service-worker redirect to out-of-scope assert_equals: expected "sw1 saw importScripts from the worker" but got "importScripts: served from network" FAIL request to sw1 scope gets service-worker redirect to out-of-scope assert_equals: expected "sw1 saw importScripts from the worker" but got "importScripts: served from network"
PASS cleanup global state PASS cleanup global state
Harness: the test ran to completion. Harness: the test ran to completion.
......
...@@ -155,7 +155,13 @@ void WorkerClassicScriptLoader::DidReceiveResponse( ...@@ -155,7 +155,13 @@ void WorkerClassicScriptLoader::DidReceiveResponse(
} }
identifier_ = identifier; identifier_ = identifier;
response_url_ = response.Url(); if (response.WasFetchedViaServiceWorker() &&
!response.OriginalURLViaServiceWorker().IsEmpty()) {
response_url_ = response.OriginalURLViaServiceWorker();
} else {
response_url_ = response.Url();
}
response_encoding_ = response.TextEncodingName(); response_encoding_ = response.TextEncodingName();
app_cache_id_ = response.AppCacheID(); app_cache_id_ = response.AppCacheID();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment