no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / workers / test / test_onLine.html
blobb0429e7d965e6fb6bd341bb32f514007187d8922
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Bug 925437: online/offline events tests.
6 Any copyright is dedicated to the Public Domain.
7 http://creativecommons.org/licenses/publicdomain/
8 -->
9 <head>
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" />
13 </head>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=925437">Mozilla Bug 925437</a>
15 <p id="display"></p>
16 <div id="content" style="display: none">
18 </div>
19 <pre id="test">
20 </pre>
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') {
42 SimpleTest.finish();
46 function doTest() {
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");
52 iosvc.offline = true;
54 info("setting iosvc.offline = false");
55 iosvc.offline = false;
57 info("setting iosvc.offline = true");
58 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;
68 });
70 SimpleTest.waitForExplicitFinish();
71 </script>
72 </body>
73 </html>