1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/test_onLine.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Bug 925437: online/offline events tests. 1.8 + 1.9 +Any copyright is dedicated to the Public Domain. 1.10 +http://creativecommons.org/licenses/publicdomain/ 1.11 +--> 1.12 +<head> 1.13 + <title>Test for Bug 925437 (worker online/offline events)</title> 1.14 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.15 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.16 +</head> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=925437">Mozilla Bug 925437</a> 1.18 +<p id="display"></p> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +</pre> 1.24 + 1.25 +<script class="testbody" type="text/javascript"> 1.26 + 1.27 +addLoadEvent(function() { 1.28 + var w = new Worker("onLine_worker.js"); 1.29 + 1.30 + w.onmessage = function(e) { 1.31 + if (e.data.type === 'ready') { 1.32 + doTest(); 1.33 + } else if (e.data.type === 'ok') { 1.34 + ok(e.data.test, e.data.message); 1.35 + } else if (e.data.type === 'finished') { 1.36 + SimpleTest.finish(); 1.37 + } 1.38 + } 1.39 + 1.40 + function doTest() { 1.41 + var iosvc = SpecialPowers.Cc["@mozilla.org/network/io-service;1"] 1.42 + .getService(SpecialPowers.Ci.nsIIOService2); 1.43 + iosvc.manageOfflineStatus = false; 1.44 + 1.45 + info("setting iosvc.offline = true"); 1.46 + iosvc.offline = true; 1.47 + 1.48 + info("setting iosvc.offline = false"); 1.49 + iosvc.offline = false; 1.50 + 1.51 + info("setting iosvc.offline = true"); 1.52 + iosvc.offline = true; 1.53 + 1.54 + for (var i = 0; i < 10; ++i) { 1.55 + iosvc.offline = !iosvc.offline; 1.56 + } 1.57 + 1.58 + info("setting iosvc.offline = false"); 1.59 + w.postMessage('lastTest'); 1.60 + iosvc.offline = false; 1.61 + } 1.62 +}); 1.63 + 1.64 +SimpleTest.waitForExplicitFinish(); 1.65 +</script> 1.66 +</body> 1.67 +</html>