mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1218135 - Remove FetchEvent.client; r=bzbarsky
This has been removed from the spec. See: https://github.com/slightlyoff/ServiceWorker/issues/723#issuecomment-123516555
This commit is contained in:
parent
136e4c8485
commit
e3652e5d9c
@ -7,13 +7,15 @@ onfetch = function(event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.client) {
|
||||
dump("ERROR: no client to post the message to!\n");
|
||||
dump("request.url=" + event.request.url + "\n");
|
||||
return;
|
||||
}
|
||||
|
||||
event.client.postMessage({type: "fetch", state: state});
|
||||
var currentState = state;
|
||||
event.waitUntil(
|
||||
clients.matchAll()
|
||||
.then(clients => {
|
||||
clients.forEach(client => {
|
||||
client.postMessage({type: "fetch", state: currentState});
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
if (event.request.url.indexOf("update") >= 0) {
|
||||
state = "update";
|
||||
|
@ -12,9 +12,6 @@
|
||||
Exposed=(ServiceWorker)]
|
||||
interface FetchEvent : ExtendableEvent {
|
||||
[SameObject] readonly attribute Request request;
|
||||
|
||||
// https://github.com/slightlyoff/ServiceWorker/issues/631
|
||||
readonly attribute Client? client; // The window issuing the request.
|
||||
readonly attribute boolean isReload;
|
||||
|
||||
[Throws]
|
||||
@ -23,6 +20,5 @@ interface FetchEvent : ExtendableEvent {
|
||||
|
||||
dictionary FetchEventInit : EventInit {
|
||||
Request request;
|
||||
Client client;
|
||||
boolean isReload;
|
||||
};
|
||||
|
@ -5,7 +5,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ServiceWorkerEvents.h"
|
||||
#include "ServiceWorkerClient.h"
|
||||
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsINetworkInterceptController.h"
|
||||
@ -72,12 +71,10 @@ FetchEvent::~FetchEvent()
|
||||
|
||||
void
|
||||
FetchEvent::PostInit(nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
|
||||
const nsACString& aScriptSpec,
|
||||
UniquePtr<ServiceWorkerClientInfo>&& aClientInfo)
|
||||
const nsACString& aScriptSpec)
|
||||
{
|
||||
mChannel = aChannel;
|
||||
mScriptSpec.Assign(aScriptSpec);
|
||||
mClientInfo = Move(aClientInfo);
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<FetchEvent>
|
||||
@ -96,8 +93,6 @@ FetchEvent::Constructor(const GlobalObject& aGlobal,
|
||||
&aOptions.mRequest.Value() : nullptr;
|
||||
e->mIsReload = aOptions.mIsReload.WasPassed() ?
|
||||
aOptions.mIsReload.Value() : false;
|
||||
e->mClient = aOptions.mClient.WasPassed() ?
|
||||
&aOptions.mClient.Value() : nullptr;
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
@ -460,24 +455,6 @@ FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv)
|
||||
aArg.AppendNativeHandler(handler);
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerClient>
|
||||
FetchEvent::GetClient()
|
||||
{
|
||||
if (!mClient) {
|
||||
if (!mClientInfo) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(worker);
|
||||
RefPtr<nsIGlobalObject> global = worker->GlobalScope();
|
||||
|
||||
mClient = new ServiceWorkerClient(global, *mClientInfo);
|
||||
}
|
||||
RefPtr<ServiceWorkerClient> client = mClient;
|
||||
return client.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(FetchEvent, ExtendableEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(FetchEvent, ExtendableEvent)
|
||||
|
||||
@ -485,7 +462,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FetchEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(ExtendableEvent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(FetchEvent, ExtendableEvent,
|
||||
mRequest, mClient, mPromise)
|
||||
mRequest, mPromise)
|
||||
|
||||
ExtendableEvent::ExtendableEvent(EventTarget* aOwner)
|
||||
: Event(aOwner, nullptr, nullptr)
|
||||
|
@ -35,8 +35,6 @@ class ResponseOrPromise;
|
||||
|
||||
BEGIN_WORKERS_NAMESPACE
|
||||
|
||||
class ServiceWorkerClient;
|
||||
|
||||
class CancelChannelRunnable final : public nsRunnable
|
||||
{
|
||||
nsMainThreadPtrHandle<nsIInterceptedChannel> mChannel;
|
||||
@ -103,10 +101,8 @@ public:
|
||||
class FetchEvent final : public ExtendableEvent
|
||||
{
|
||||
nsMainThreadPtrHandle<nsIInterceptedChannel> mChannel;
|
||||
RefPtr<ServiceWorkerClient> mClient;
|
||||
RefPtr<Request> mRequest;
|
||||
nsCString mScriptSpec;
|
||||
UniquePtr<ServiceWorkerClientInfo> mClientInfo;
|
||||
RefPtr<Promise> mPromise;
|
||||
bool mIsReload;
|
||||
bool mWaitToRespond;
|
||||
@ -125,8 +121,7 @@ public:
|
||||
}
|
||||
|
||||
void PostInit(nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
|
||||
const nsACString& aScriptSpec,
|
||||
UniquePtr<ServiceWorkerClientInfo>&& aClientInfo);
|
||||
const nsACString& aScriptSpec);
|
||||
|
||||
static already_AddRefed<FetchEvent>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
@ -146,9 +141,6 @@ public:
|
||||
return mRequest;
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerClient>
|
||||
GetClient();
|
||||
|
||||
bool
|
||||
IsReload() const
|
||||
{
|
||||
|
@ -915,7 +915,6 @@ class FetchEventRunnable : public ExtendableFunctionalEventWorkerRunnable
|
||||
const nsCString mScriptSpec;
|
||||
nsTArray<nsCString> mHeaderNames;
|
||||
nsTArray<nsCString> mHeaderValues;
|
||||
UniquePtr<ServiceWorkerClientInfo> mClientInfo;
|
||||
nsCString mSpec;
|
||||
nsCString mMethod;
|
||||
bool mIsReload;
|
||||
@ -940,7 +939,6 @@ public:
|
||||
aWorkerPrivate, aKeepAliveToken, aRegistration)
|
||||
, mInterceptedChannel(aChannel)
|
||||
, mScriptSpec(aScriptSpec)
|
||||
, mClientInfo(Move(aClientInfo))
|
||||
, mIsReload(aIsReload)
|
||||
, mIsHttpChannel(false)
|
||||
, mRequestMode(RequestMode::No_cors)
|
||||
@ -1161,7 +1159,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
event->PostInit(mInterceptedChannel, mScriptSpec, Move(mClientInfo));
|
||||
event->PostInit(mInterceptedChannel, mScriptSpec);
|
||||
event->SetTrusted(true);
|
||||
|
||||
RefPtr<EventTarget> target = do_QueryObject(aWorkerPrivate->GlobalScope());
|
||||
|
@ -1,7 +1,14 @@
|
||||
self.addEventListener("fetch", function(event) {
|
||||
var resource = event.request.url.split('/').pop();
|
||||
if (event.client) {
|
||||
event.client.postMessage({context: event.request.context,
|
||||
resource: resource});
|
||||
}
|
||||
event.waitUntil(
|
||||
clients.matchAll()
|
||||
.then(clients => {
|
||||
clients.forEach(client => {
|
||||
if (client.url.includes("plugins.html")) {
|
||||
client.postMessage({context: event.request.context,
|
||||
resource: resource});
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -1,6 +0,0 @@
|
||||
var CLIENT_URL =
|
||||
"http://mochi.test:8888/tests/dom/workers/test/serviceworkers/sw_clients/dummy.html"
|
||||
|
||||
self.addEventListener("fetch", function(event) {
|
||||
event.client.postMessage({status: event.client.url === CLIENT_URL});
|
||||
});
|
@ -173,8 +173,6 @@ support-files =
|
||||
opaque_intercept_worker.js
|
||||
notify_loaded.js
|
||||
test_request_context.js
|
||||
fetch_event_client.js
|
||||
sw_clients/dummy.html
|
||||
fetch/plugin/worker.js
|
||||
fetch/plugin/plugins.html
|
||||
eventsource/*
|
||||
@ -271,7 +269,6 @@ skip-if = toolkit == "android" || toolkit == "gonk"
|
||||
[test_workerUpdate.html]
|
||||
[test_workerupdatefoundevent.html]
|
||||
[test_opaque_intercept.html]
|
||||
[test_fetch_event_client_postmessage.html]
|
||||
[test_xslt.html]
|
||||
[test_escapedSlashes.html]
|
||||
[test_eventsource_intercept.html]
|
||||
|
@ -1,19 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1158735 - Dummy page</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" >
|
||||
window.onload = function() {
|
||||
navigator.serviceWorker.ready.then(function(swr) {
|
||||
fetch("foo.txt");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,73 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1158735 - FetchEvent.client asserting in onFetch when there's no document.</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test"></pre>
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.requestCompleteLog();
|
||||
|
||||
var registration;
|
||||
function start() {
|
||||
return navigator.serviceWorker.register("fetch_event_client.js", { scope: "./"})
|
||||
.then((swr) => registration = swr);
|
||||
}
|
||||
|
||||
function unregister() {
|
||||
return registration.unregister().then(function(result) {
|
||||
ok(result, "Unregister should return true.");
|
||||
}, function(e) {
|
||||
dump("Unregistering the SW failed with " + e + "\n");
|
||||
});
|
||||
}
|
||||
|
||||
function testFetchEvent() {
|
||||
var p = new Promise(function(resolve, reject) {
|
||||
var content = document.getElementById("content");
|
||||
ok(content, "parent exists.");
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('src', "sw_clients/dummy.html");
|
||||
content.appendChild(iframe);
|
||||
|
||||
var w = iframe.contentWindow;
|
||||
w.navigator.serviceWorker.onmessage = function(msg) {
|
||||
ok(msg.data.status, "Receive message posted by client successfully");
|
||||
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
start()
|
||||
.then(testFetchEvent)
|
||||
.then(unregister)
|
||||
.then(function() {
|
||||
}).catch(function(e) {
|
||||
ok(false, "Some test failed with error " + e);
|
||||
}).then(SimpleTest.finish);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
['dom.serviceWorkers.interception.enabled', true],
|
||||
]}, runTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,9 +1,12 @@
|
||||
onfetch = function(event) {
|
||||
if (!event.client) {
|
||||
dump("ERROR: event doesnt have a client");
|
||||
}
|
||||
|
||||
event.client.postMessage("continue");
|
||||
event.waitUntil(
|
||||
clients.matchAll()
|
||||
.then(clients => {
|
||||
clients.forEach(client => {
|
||||
client.postMessage("continue");
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
// never resolve
|
||||
event.respondWith(new Promise(function(res, rej) {}));
|
||||
|
Loading…
Reference in New Issue
Block a user