var gState = 0; /** *Afteralltheon/offlinehandlersrun, *gStateisexpectedtobeequaltoMAX_STATE.
*/ var MAX_STATE;
function trace(text) { var t = text.replace(/&/g, "&" + "amp;").replace(/</g, "&" + "lt;") + "<br>"; //document.getElementById("display").innerHTML += t;
}
/** *Returnsahandlerfunctionforanonline/offlineevent.Thereturnedhandler *ensuresthepassedeventobjecthasexpectedpropertiesandthatthehandler *iscalledattherightmoment(accordingtothegStatevariable). *@paramnameTemplateThestringidentifyingthehanlder.'%1'inthat *stringwillbereplacedwiththeeventname. *@parameventName'online'or'offline' *@paramexpectedStatesanarraylistingthepossiblevaluesofgStateatthe *momentthehandleriscalled.Thehandlerincreases *gStatebyonebeforecheckingifit'slistedin *expectedStates.
*/ function makeHandler(nameTemplate, eventName, expectedStates) { returnfunction (e) { var name = nameTemplate.replace(/%1/, eventName);
++gState;
trace(name + ": gState=" + gState);
ok(
expectedStates.includes(gState), "handlers called in the right order: " +
name + " is called, " + "gState=" +
gState + ", expectedStates=" +
expectedStates
);
ok(e.constructor == Event, "event should be an Event");
ok(e.type == eventName, "event type should be " + eventName);
ok(!e.bubbles, "event should not bubble");
ok(!e.cancelable, "event should not be cancelable");
ok(e.target == window, "target should be the window");
};
}
function doTest() { var iosvc = SpecialPowers.Cc["@mozilla.org/network/io-service;1"].getService(
SpecialPowers.Ci.nsIIOService
);
iosvc.manageOfflineStatus = false;
iosvc.offline = false;
ok(
navigator.onLine, "navigator.onLine should be true, since we've just " + "set nsIIOService.offline to false"
);
gState = 0;
trace("setting iosvc.offline = true");
iosvc.offline = true;
trace("done setting iosvc.offline = true");
ok(
!navigator.onLine, "navigator.onLine should be false when iosvc.offline == true"
);
ok(
gState == window.MAX_STATE, "offline event: all registered handlers should have been invoked, " + "actual: " +
gState
);
gState = 0;
trace("setting iosvc.offline = false");
iosvc.offline = false;
trace("done setting iosvc.offline = false");
ok(
navigator.onLine, "navigator.onLine should be true when iosvc.offline == false"
);
ok(
gState == window.MAX_STATE, "online event: all registered handlers should have been invoked, " + "actual: " +
gState
);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.