2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
6 /* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */
9 dump("Test for Bug 925437: worker: " + text + "\n");
12 function ok(test, message) {
13 postMessage({ type: "ok", test, message });
17 * Returns a handler function for an online/offline event. The returned handler
18 * ensures the passed event object has expected properties and that the handler
19 * is called at the right moment (according to the gState variable).
20 * @param nameTemplate The string identifying the hanlder. '%1' in that
21 * string will be replaced with the event name.
22 * @param eventName 'online' or 'offline'
23 * @param expectedState value of gState at the moment the handler is called.
24 * The handler increases gState by one before checking
25 * if it matches expectedState.
27 function makeHandler(nameTemplate, eventName, expectedState, prefix, custom) {
30 var name = nameTemplate.replace(/%1/, eventName);
31 ok(e.constructor == Event, prefix + "event should be an Event");
32 ok(e.type == eventName, prefix + "event type should be " + eventName);
33 ok(!e.bubbles, prefix + "event should not bubble");
34 ok(!e.cancelable, prefix + "event should not be cancelable");
37 prefix + "the event target should be the worker scope"
40 eventName == "online" ? navigator.onLine : !navigator.onLine,
44 " should reflect event " +