mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1170817 - Fix unsubscribe() resolution value. r=dougt
This commit is contained in:
parent
4aa5df87aa
commit
719564aef0
@ -92,10 +92,10 @@ PushSubscription.prototype = {
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "PushService:Unregister:OK":
|
||||
resolver.resolve(false);
|
||||
resolver.resolve(true);
|
||||
break;
|
||||
case "PushService:Unregister:KO":
|
||||
resolver.reject(true);
|
||||
resolver.resolve(false);
|
||||
break;
|
||||
default:
|
||||
debug("NOT IMPLEMENTED! receiveMessage for " + aMessage.name);
|
||||
|
@ -15,6 +15,8 @@ skip-if = os == "android" || toolkit == "gonk"
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_multiple_register_during_service_activation.html]
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_unregister.html]
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_multiple_register_different_scope.html]
|
||||
skip-if = os == "android" || toolkit == "gonk"
|
||||
[test_try_registering_offline_disabled.html]
|
||||
|
93
dom/push/test/test_unregister.html
Normal file
93
dom/push/test/test_unregister.html
Normal file
@ -0,0 +1,93 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 1170817: Push tests.
|
||||
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1170817</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=1170817">Mozilla Bug 1170817</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; });
|
||||
}
|
||||
|
||||
function unregisterSW() {
|
||||
return registration.unregister().then(function(result) {
|
||||
ok(result, "Unregister should return true.");
|
||||
}, function(e) {
|
||||
dump("Unregistering the SW failed with " + e + "\n");
|
||||
});
|
||||
}
|
||||
|
||||
function setupPushNotification(swr) {
|
||||
return swr.pushManager.subscribe().then(
|
||||
pushSubscription => {
|
||||
ok(true, "successful registered for push notification");
|
||||
return pushSubscription;
|
||||
}, error => {
|
||||
ok(false, "could not register for push notification");
|
||||
});
|
||||
}
|
||||
|
||||
function unregisterPushNotification(pushSubscription) {
|
||||
return pushSubscription.unsubscribe().then(
|
||||
result => {
|
||||
ok(result, "unsubscribe() on existing subscription should return true.");
|
||||
return pushSubscription;
|
||||
}, error => {
|
||||
ok(false, "unsubscribe() should never fail.");
|
||||
});
|
||||
}
|
||||
|
||||
function unregisterAgain(pushSubscription) {
|
||||
return pushSubscription.unsubscribe().then(
|
||||
result => {
|
||||
ok(!result, "unsubscribe() on previously unsubscribed subscription should return false.");
|
||||
return pushSubscription;
|
||||
}, error => {
|
||||
ok(false, "unsubscribe() should never fail.");
|
||||
});
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
start()
|
||||
.then(setupPushNotification)
|
||||
.then(unregisterPushNotification)
|
||||
.then(unregisterAgain)
|
||||
.then(unregisterSW)
|
||||
.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>
|
||||
|
Loading…
Reference in New Issue
Block a user