Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
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 type="text/javascript" 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 doTest();
30 } else if (e.data.type === 'ok') {
31 ok(e.data.test, e.data.message);
32 } else if (e.data.type === 'finished') {
33 SimpleTest.finish();
34 }
35 }
37 function doTest() {
38 var iosvc = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
39 .getService(SpecialPowers.Ci.nsIIOService2);
40 iosvc.manageOfflineStatus = false;
42 info("setting iosvc.offline = true");
43 iosvc.offline = true;
45 info("setting iosvc.offline = false");
46 iosvc.offline = false;
48 info("setting iosvc.offline = true");
49 iosvc.offline = true;
51 for (var i = 0; i < 10; ++i) {
52 iosvc.offline = !iosvc.offline;
53 }
55 info("setting iosvc.offline = false");
56 w.postMessage('lastTest');
57 iosvc.offline = false;
58 }
59 });
61 SimpleTest.waitForExplicitFinish();
62 </script>
63 </body>
64 </html>