// Keep track of how many fullscreenChange enters we've received, so that // we can balance them with the number of exits we receive. We reset this // to 0 when we load a test. var fullscreenChangeEnters = 0;
addLoadEvent(function () {
info(`Resetting fullscreen enter count.`);
fullscreenChangeEnters = 0; if (typeof start !== "undefined") { // Delay one event loop to stabilize the initial state of the page.
SimpleTest.executeSoon(start);
}
});
// Returns true if the window believes it is in fullscreen. This may be true even // before an asynchronous fullscreen transition is complete. function inFullscreenMode(win) { return win.document.fullscreenElement;
}
// Adds a listener that will be called once a fullscreen transition // is complete. When type==='enter', callback is called when we've // received a fullscreenchange event, and the fullscreen transition is // complete. When type==='exit', callback is called when we've // received a fullscreenchange event and the window is out of // fullscreen. inDoc is the document which the listeners are added on, // if absent, the listeners are added to the current document. function addFullscreenChangeContinuation(type, callback, inDoc) { var doc = inDoc || document; var topWin = doc.defaultView.top; function checkCondition() { if (type == "enter") {
fullscreenChangeEnters++; return inFullscreenMode(topWin);
} elseif (type == "exit") {
fullscreenChangeEnters--; return fullscreenChangeEnters
? inFullscreenMode(topWin)
: !inFullscreenMode(topWin);
} else { throw"'type' must be either 'enter', or 'exit'.";
}
} function onFullscreenChange(event) {
doc.removeEventListener("fullscreenchange", onFullscreenChange);
ok(checkCondition(), `Should ${type} fullscreen.`);
// Invoke the callback after the browsingContext has become active // (or we've timed out waiting for it to become active).
let bc = SpecialPowers.wrap(topWin).browsingContext;
TestUtils.waitForCondition(
() => bc.isActive, "browsingContext should become active"
)
.catch(e =>
ok(false, `Wait for browsingContext.isActive failed with ${e}`)
)
.finally(() => {
requestAnimationFrame(() => setTimeout(() => callback(event), 0), 0);
});
}
doc.addEventListener("fullscreenchange", onFullscreenChange);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
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.