mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1151082 - RequestSyncAPI - avoid infinite loop when processing pending messages, r=ehsan
This commit is contained in:
parent
e9c2da8c5f
commit
ce8084617b
@ -814,7 +814,7 @@ this.RequestSyncService = {
|
||||
this._pendingOperation = false;
|
||||
|
||||
// managing the pending messages now that the initialization is completed.
|
||||
while (this._pendingMessages.length) {
|
||||
while (this._pendingMessages.length && !this._pendingOperation) {
|
||||
this.receiveMessage(this._pendingMessages.shift());
|
||||
}
|
||||
},
|
||||
|
@ -17,3 +17,4 @@ skip-if = !(buildapp == 'b2g' && toolkit == 'gonk')
|
||||
[test_runNow.html]
|
||||
run-if = buildapp == 'b2g' && toolkit == 'gonk'
|
||||
[test_promise.html]
|
||||
[test_bug1151082.html]
|
||||
|
79
dom/requestsync/tests/test_bug1151082.html
Normal file
79
dom/requestsync/tests/test_bug1151082.html
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for RequestSync bug 1151082</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="common_basic.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7">
|
||||
|
||||
|
||||
var tests = [
|
||||
function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.requestSync.enabled", true],
|
||||
["dom.requestSync.minInterval", 1],
|
||||
["dom.ignore_webidl_scope_checks", true]]}, runTests);
|
||||
},
|
||||
|
||||
function() {
|
||||
SpecialPowers.pushPermissions(
|
||||
[{ "type": "requestsync-manager", "allow": 1, "context": document } ], runTests);
|
||||
},
|
||||
|
||||
function() {
|
||||
if (SpecialPowers.isMainProcess()) {
|
||||
SpecialPowers.Cu.import("resource://gre/modules/RequestSyncService.jsm");
|
||||
}
|
||||
runTests();
|
||||
},
|
||||
|
||||
function() {
|
||||
counter = 2;
|
||||
function registerCb() {
|
||||
if (!--counter) {
|
||||
ok(true, "All the registrations are done.");
|
||||
runTests();
|
||||
}
|
||||
}
|
||||
|
||||
navigator.sync.register('foobar', { minInterval: 5, wakeUpPage:'/' }).then(registerCb, genericError);
|
||||
navigator.sync.register('barfoo', { minInterval: 5, wakeUpPage:'/' }).then(registerCb, genericError);
|
||||
},
|
||||
|
||||
function() {
|
||||
counter = 2;
|
||||
function unregisterCb() {
|
||||
if (!--counter) {
|
||||
ok(true, "All the unregistrations are done.");
|
||||
runTests();
|
||||
}
|
||||
}
|
||||
|
||||
navigator.sync.unregister('foobar').then(unregisterCb, genericError);
|
||||
navigator.sync.unregister('barfoo').then(unregisterCb, genericError);
|
||||
}
|
||||
];
|
||||
|
||||
function runTests() {
|
||||
if (!tests.length) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
test();
|
||||
}
|
||||
|
||||
function finish() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTests();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user