4 Bug 925437: online/offline events tests.
6 Any copyright is dedicated to the Public Domain.
7 http://creativecommons.org/licenses/publicdomain/
10 <title>Test for Bug
925437 (worker online/offline events)
</title>
11 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
12 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=925437">Mozilla Bug
925437</a>
16 <div id=
"content" style=
"display: none">
22 <script class=
"testbody" type=
"text/javascript">
24 addLoadEvent(function() {
25 var w = new Worker(
"onLine_worker.js");
27 w.onmessage = function(e) {
28 if (e.data.type === 'ready') {
29 // XXX Important trick here.
31 // Setting iosvc.offline would trigger a sync notifyObservers call, and if
32 // there exists a preloaded about:newtab (see tabbrowser._handleNewTab),
33 // that tab will be notified.
35 // This implies a sync call across different tabGroups, and will hit the
36 // assertion in SchedulerGroup::ValidateAccess(). So use executeSoon to
37 // re-dispatch an unlabeled runnable to the event queue.
38 SpecialPowers.executeSoon(doTest);
39 } else if (e.data.type === 'ok') {
40 ok(e.data.test, e.data.message);
41 } else if (e.data.type === 'finished') {
47 var iosvc = SpecialPowers.Cc[
"@mozilla.org/network/io-service;1"]
48 .getService(SpecialPowers.Ci.nsIIOService);
49 iosvc.manageOfflineStatus = false;
51 info(
"setting iosvc.offline = true");
54 info(
"setting iosvc.offline = false");
55 iosvc.offline = false;
57 info(
"setting iosvc.offline = true");
60 for (var i =
0; i <
10; ++i) {
61 iosvc.offline = !iosvc.offline;
64 info(
"setting iosvc.offline = false");
65 w.postMessage('lastTest');
66 iosvc.offline = false;
70 SimpleTest.waitForExplicitFinish();