mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out bug 1205109 for Push mochitest failure.
This commit is contained in:
parent
0d952f7717
commit
f81945138a
@ -44,7 +44,7 @@ gDebuggingEnabled = prefs.get("debug");
|
||||
|
||||
const kCHILD_PROCESS_MESSAGES = ["Push:Register", "Push:Unregister",
|
||||
"Push:Registration", "Push:RegisterEventNotificationListener",
|
||||
"Push:Reset", "child-process-shutdown"];
|
||||
"child-process-shutdown"];
|
||||
|
||||
const PUSH_SERVICE_UNINIT = 0;
|
||||
const PUSH_SERVICE_INIT = 1; // No serverURI
|
||||
@ -1047,7 +1047,6 @@ this.PushService = {
|
||||
return null;
|
||||
}
|
||||
|
||||
let name = aMessage.name.slice("Push:".length);
|
||||
let mm = aMessage.target.QueryInterface(Ci.nsIMessageSender);
|
||||
let pageRecord = aMessage.data;
|
||||
|
||||
@ -1058,7 +1057,7 @@ this.PushService = {
|
||||
requestID: pageRecord.requestID,
|
||||
error: "SecurityError"
|
||||
};
|
||||
mm.sendAsyncMessage("PushService:" + name + ":KO", message);
|
||||
mm.sendAsyncMessage("PushService:Register:KO", message);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1071,24 +1070,11 @@ this.PushService = {
|
||||
requestID: pageRecord.requestID,
|
||||
error: "SecurityError"
|
||||
};
|
||||
mm.sendAsyncMessage("PushService:" + name + ":KO", message);
|
||||
mm.sendAsyncMessage("PushService:Register:KO", message);
|
||||
return;
|
||||
}
|
||||
|
||||
this[name.toLowerCase()](pageRecord, mm);
|
||||
},
|
||||
|
||||
reset: function(aPageRecord, aMessageManager) {
|
||||
this.dropRegistrations().then(() => {
|
||||
aMessageManager.sendAsyncMessage("PushService:Reset:OK", {
|
||||
requestID: aPageRecord.requestID,
|
||||
});
|
||||
}, error => {
|
||||
aMessageManager.sendAsyncMessage("PushService:Reset:KO", {
|
||||
requestID: aPageRecord.requestID,
|
||||
error: error,
|
||||
});
|
||||
});
|
||||
this[aMessage.name.slice("Push:".length).toLowerCase()](pageRecord, mm);
|
||||
},
|
||||
|
||||
register: function(aPageRecord, aMessageManager) {
|
||||
|
@ -4,16 +4,15 @@
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||
<script>
|
||||
|
||||
function waitOnWorkerMessage(type)
|
||||
|
||||
function waitOnPushMessage(pushSubscription)
|
||||
{
|
||||
var p = new Promise(function(res, rej) {
|
||||
function onMessage(e) {
|
||||
if (e.data.type == type) {
|
||||
navigator.serviceWorker.removeEventListener("message", onMessage);
|
||||
navigator.serviceWorker.onmessage = function(e) {
|
||||
if (e.data.type == "finished") {
|
||||
(e.data.okay == "yes" ? res : rej)(e.data);
|
||||
}
|
||||
}
|
||||
navigator.serviceWorker.addEventListener("message", onMessage);
|
||||
};
|
||||
});
|
||||
return p;
|
||||
}
|
||||
|
@ -20,8 +20,6 @@ skip-if = os == "android" || toolkit == "gonk"
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_multiple_register_different_scope.html]
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_subscription_change.html]
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_data.html]
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
# Disabled for too many intermittent failures (bug 1164432)
|
||||
|
@ -36,17 +36,19 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
var p = new Promise(function(res, rej) {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.id = "controlledFrame";
|
||||
iframe.src = "/tests/dom/push/test/frame.html";
|
||||
iframe.src = "http://mochi.test:8888/tests/dom/push/test/frame.html";
|
||||
|
||||
iframe.onload = () => res();
|
||||
iframe.onload = function() {
|
||||
res(swr)
|
||||
}
|
||||
controlledFrame = iframe;
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
return p;
|
||||
}
|
||||
|
||||
function subscribe() {
|
||||
return registration.pushManager.subscribe();
|
||||
function subscribe(swr) {
|
||||
return swr.pushManager.subscribe();
|
||||
}
|
||||
|
||||
function sendRequestToWorker(request) {
|
||||
@ -77,7 +79,7 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
function waitForMessage(pushSubscription, message) {
|
||||
return Promise.all([
|
||||
controlledFrame.contentWindow.waitOnWorkerMessage("finished"),
|
||||
controlledFrame.contentWindow.waitOnPushMessage(pushSubscription),
|
||||
webpush(pushSubscription, message),
|
||||
]).then(([message]) => message);
|
||||
}
|
||||
@ -133,8 +135,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
is(text, "Hi! \ud83d\udc40", "Wrong blob data for message with emoji");
|
||||
// Send a blank message.
|
||||
return Promise.all([
|
||||
controlledFrame.contentWindow.waitOnWorkerMessage("finished"),
|
||||
fetch("/tests/dom/push/test/push-server.sjs", {
|
||||
controlledFrame.contentWindow.waitOnPushMessage(pushSubscription),
|
||||
fetch("http://mochi.test:8888/tests/dom/push/test/push-server.sjs", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"X-Push-Method": "POST",
|
||||
|
@ -32,9 +32,11 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
var p = new Promise(function(res, rej) {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.id = "controlledFrame";
|
||||
iframe.src = "/tests/dom/push/test/frame.html";
|
||||
iframe.src = "http://mochi.test:8888/tests/dom/push/test/frame.html";
|
||||
|
||||
iframe.onload = () => res(swr);
|
||||
iframe.onload = function() {
|
||||
res(swr)
|
||||
}
|
||||
controlledFrame = iframe;
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
@ -103,7 +105,7 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
|
||||
function waitForPushNotification(pushSubscription) {
|
||||
var p = controlledFrame.contentWindow.waitOnWorkerMessage("finished");
|
||||
var p = controlledFrame.contentWindow.waitOnPushMessage();
|
||||
sendPushToPushServer(pushSubscription.endpoint);
|
||||
return p.then(function() {
|
||||
return pushSubscription;
|
||||
|
@ -1,136 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 1205109: Make `pushsubscriptionchange` extendable.
|
||||
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1205109</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||
</head>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1205109">Mozilla Bug 1205109</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var registration;
|
||||
|
||||
function start() {
|
||||
return navigator.serviceWorker.register("worker.js" + "?" + (Math.random()), {scope: "."})
|
||||
.then(swr => { registration = swr; return swr; });
|
||||
}
|
||||
|
||||
var controlledFrame;
|
||||
function createControlledIFrame(swr) {
|
||||
var p = new Promise(function(res, rej) {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.id = "controlledFrame";
|
||||
iframe.src = "/tests/dom/push/test/frame.html";
|
||||
|
||||
iframe.onload = () => res();
|
||||
controlledFrame = iframe;
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
return p;
|
||||
}
|
||||
|
||||
function subscribe() {
|
||||
return registration.pushManager.subscribe();
|
||||
}
|
||||
|
||||
function unsubscribe(pushSubscription) {
|
||||
controlledFrame.parentNode.removeChild(controlledFrame);
|
||||
controlledFrame = null;
|
||||
return pushSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
function unregister() {
|
||||
return registration.unregister();
|
||||
}
|
||||
|
||||
function resetSubscriptions() {
|
||||
return new Promise((resolve, reject) => {
|
||||
var requestID = SpecialPowers.Cc["@mozilla.org/uuid-generator;1"]
|
||||
.getService(SpecialPowers.Ci
|
||||
.nsIUUIDGenerator)
|
||||
.generateUUID().toString();
|
||||
var cpmm = SpecialPowers.Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(SpecialPowers.Ci
|
||||
.nsISyncMessageSender);
|
||||
var listener = {
|
||||
receiveMessage: function(message) {
|
||||
message = SpecialPowers.Cu.waiveXrays(message);
|
||||
var isSuccess = message.name == "PushService:Reset:OK";
|
||||
var isFailure = !isSuccess && message.name == "PushService:Reset:KO";
|
||||
if ((isSuccess || isFailure) &&
|
||||
message.data.requestID == requestID) {
|
||||
|
||||
cpmm.removeMessageListener("PushService:Reset:OK", listener);
|
||||
cpmm.removeMessageListener("PushService:Reset:KO", listener);
|
||||
(isSuccess ? resolve : reject)(message.data);
|
||||
}
|
||||
},
|
||||
};
|
||||
cpmm.addMessageListener("PushService:Reset:OK", listener);
|
||||
cpmm.addMessageListener("PushService:Reset:KO", listener);
|
||||
|
||||
cpmm.sendAsyncMessage("Push:Reset", {
|
||||
requestID: requestID,
|
||||
scope: ".",
|
||||
}, null, SpecialPowers.Services.scriptSecurityManager
|
||||
.getSystemPrincipal());
|
||||
});
|
||||
}
|
||||
|
||||
function changeSubscription(oldSubscription) {
|
||||
return Promise.all([
|
||||
controlledFrame.contentWindow.waitOnWorkerMessage("changed"),
|
||||
resetSubscriptions(),
|
||||
]).then(() =>
|
||||
registration.pushManager.getSubscription()
|
||||
).then(newSubscription => {
|
||||
ok(newSubscription.endpoint != oldSubscription.endpoint,
|
||||
"Expected new push endpoint");
|
||||
|
||||
var oldKey = new Uint8Array(oldSubscription.getKey("p256dh"));
|
||||
var newKey = new Uint8Array(newSubscription.getKey("p256dh"));
|
||||
ok(!oldKey.every((byte, index) => byte == newKey[index]),
|
||||
"Expected new key share");
|
||||
|
||||
return newSubscription;
|
||||
});
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
start()
|
||||
.then(createControlledIFrame)
|
||||
.then(subscribe)
|
||||
.then(changeSubscription)
|
||||
.then(unsubscribe)
|
||||
.then(unregister)
|
||||
.catch(function(e) {
|
||||
ok(false, "Some test failed with error " + e);
|
||||
}).then(SimpleTest.finish);
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.push.enabled", true],
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true]
|
||||
]}, runTest);
|
||||
SpecialPowers.addPermission('push', true, document);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -3,7 +3,6 @@
|
||||
|
||||
this.onpush = handlePush;
|
||||
this.onmessage = handleMessage;
|
||||
this.onpushsubscriptionchange = handleSubscriptionChange;
|
||||
|
||||
function getJSON(data) {
|
||||
var result = {
|
||||
@ -56,13 +55,3 @@ function handleMessage(event) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function handleSubscriptionChange(event) {
|
||||
event.waitUntil(self.registration.pushManager.subscribe().then(subscription =>
|
||||
self.clients.matchAll()
|
||||
).then(([client]) => {
|
||||
client.postMessage({type: "changed", okay: "yes"});
|
||||
}).catch(err => {
|
||||
dump("handleSubscriptionChange: Error notifying client: " + err + "\n");
|
||||
}));
|
||||
}
|
||||
|
@ -2390,27 +2390,19 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
|
||||
nsRefPtr<EventTarget> target = aWorkerPrivate->GlobalScope();
|
||||
WorkerGlobalScope* globalScope = aWorkerPrivate->GlobalScope();
|
||||
|
||||
ExtendableEventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
nsRefPtr<Event> event = NS_NewDOMEvent(globalScope, nullptr, nullptr);
|
||||
|
||||
ErrorResult result;
|
||||
nsRefPtr<ExtendableEvent> event =
|
||||
ExtendableEvent::Constructor(target,
|
||||
NS_LITERAL_STRING("pushsubscriptionchange"),
|
||||
init);
|
||||
nsresult rv = event->InitEvent(NS_LITERAL_STRING("pushsubscriptionchange"),
|
||||
false, false);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
event->SetTrusted(true);
|
||||
|
||||
nsRefPtr<Promise> waitUntilPromise =
|
||||
DispatchExtendableEventOnWorkerScope(aCx, aWorkerPrivate->GlobalScope(), event);
|
||||
if (waitUntilPromise) {
|
||||
nsRefPtr<KeepAliveHandler> handler = new KeepAliveHandler(mServiceWorker);
|
||||
waitUntilPromise->AppendNativeHandler(handler);
|
||||
}
|
||||
|
||||
globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user