/** Test for Bug 742376 **/
let Cc = SpecialPowers.Cc;
let Ci = SpecialPowers.Ci;
let dss = Cc["@mozilla.org/devicesensors;1"].getService(Ci.nsIDeviceSensors);
function hasLightListeners() {
return dss.hasWindowListener(Ci.nsIDeviceSensorData.TYPE_LIGHT, window);
}
async function test_event_presence(prefName, eventCheck, eventName) {
function dumbListener(event) {}
function dumbListener2(event) {}
function dumbListener3(event) {}
is(hasOrientationListeners(), true, "Listeners should have been added");
await new Promise(resolve => {
window.setTimeout(function() {
window.removeEventListener("deviceorientation", dumbListener);
is(hasOrientationListeners(), true, "Only some listeners should have been removed");
window.setTimeout(function() {
window.removeEventListener("deviceorientation", dumbListener2);
window.setTimeout(function() {
is(hasOrientationListeners(), false, "Listeners should have been removed");
resolve();
}, 0);
}, 0);
}, 0);
});
await new Promise(resolve => {
window.ondeviceorientation = function() {}
window.setTimeout(function() {
is(hasOrientationListeners(), true, "Handler should have been added");
window.ondeviceorientation = null;
window.setTimeout(function() {
is(hasOrientationListeners(), false, "Handler should have been removed");
resolve();
}, 0);
}, 0);
});
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.