mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 1667836 - Fix some bugs in PerformanceEventTiming related tests r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D102038
This commit is contained in:
parent
b03a010048
commit
6523069aac
@ -26,6 +26,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=760851
|
|||||||
window.performance.onresourcetimingbufferfull = function() {};
|
window.performance.onresourcetimingbufferfull = function() {};
|
||||||
|
|
||||||
function checkAttributesMatch(obj, jsonObj) {
|
function checkAttributesMatch(obj, jsonObj) {
|
||||||
|
// EventCounts isn't going to converted to a JSON string
|
||||||
|
if (obj instanceof EventCounts) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (typeof(obj) !== "object") {
|
if (typeof(obj) !== "object") {
|
||||||
throw "Expected obj to be of type \"object\". Test failed.";
|
throw "Expected obj to be of type \"object\". Test failed.";
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,13 @@
|
|||||||
});
|
});
|
||||||
const childFrameEntriesPromise = new Promise(resolve => {
|
const childFrameEntriesPromise = new Promise(resolve => {
|
||||||
window.addEventListener("message", (event) => {
|
window.addEventListener("message", (event) => {
|
||||||
t.step(() => {
|
// testdriver-complete is a webdriver internal event
|
||||||
validateChildFrameEntries(event.data);
|
if (event.data.type != "testdriver-complete") {
|
||||||
});
|
t.step(() => {
|
||||||
resolve();
|
validateChildFrameEntries(event.data);
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
let iframe = document.getElementById('iframe');
|
let iframe = document.getElementById('iframe');
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
<div id='target'>Target</div>
|
<div id='target'>Target</div>
|
||||||
<script>
|
<script>
|
||||||
promise_test(async t => {
|
promise_test(async t => {
|
||||||
return testEventType(t, 'mouseenter');
|
// PointerMove also creates mouseenter events on the body
|
||||||
|
return testEventType(t, 'mouseenter', true);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
<div id='target'>Target</div>
|
<div id='target'>Target</div>
|
||||||
<script>
|
<script>
|
||||||
promise_test(async t => {
|
promise_test(async t => {
|
||||||
return testEventType(t, 'mouseleave');
|
// Loose event because a mouseleave from html -> body also occurs
|
||||||
|
return testEventType(t, 'mouseleave', true);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
<div id='target'>Target</div>
|
<div id='target'>Target</div>
|
||||||
<script>
|
<script>
|
||||||
promise_test(async t => {
|
promise_test(async t => {
|
||||||
return testEventType(t, 'pointerenter');
|
// A looseCount because the first move of pointerenter causes a
|
||||||
|
// `pointerenter` on body
|
||||||
|
return testEventType(t, 'pointerenter', true);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
<div id='target'>Target</div>
|
<div id='target'>Target</div>
|
||||||
<script>
|
<script>
|
||||||
promise_test(async t => {
|
promise_test(async t => {
|
||||||
return testEventType(t, 'pointerleave');
|
// Loose event because a pointerleave from html -> body also occurs
|
||||||
|
return testEventType(t, 'pointerleave', true);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -70,6 +70,13 @@ function clickAndBlockMain(id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitForTick() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
window.requestAnimationFrame(resolve);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
// Add a PerformanceObserver and observe with a durationThreshold of |dur|. This test will
|
// Add a PerformanceObserver and observe with a durationThreshold of |dur|. This test will
|
||||||
// attempt to check that the duration is appropriately checked by:
|
// attempt to check that the duration is appropriately checked by:
|
||||||
// * Asserting that entries received have a duration which is the smallest multiple of 8
|
// * Asserting that entries received have a duration which is the smallest multiple of 8
|
||||||
@ -150,11 +157,12 @@ function applyAction(eventType, target) {
|
|||||||
// Reset by clicking outside of the target.
|
// Reset by clicking outside of the target.
|
||||||
.pointerMove(0, 0)
|
.pointerMove(0, 0)
|
||||||
.pointerDown()
|
.pointerDown()
|
||||||
.pointerUp();
|
|
||||||
} else if (eventType === 'mouseenter' || eventType === 'mouseover'
|
} else if (eventType === 'mouseenter' || eventType === 'mouseover'
|
||||||
|| eventType === 'pointerenter' || eventType === 'pointerover') {
|
|| eventType === 'pointerenter' || eventType === 'pointerover') {
|
||||||
// Move outside of the target and then back inside.
|
// Move outside of the target and then back inside.
|
||||||
actions.pointerMove(0, 0)
|
// Moving it to 0, 1 because 0, 0 doesn't cause the pointer to
|
||||||
|
// move in Firefox. See https://github.com/w3c/webdriver/issues/1545
|
||||||
|
actions.pointerMove(0, 1)
|
||||||
.pointerMove(0, 0, {origin: target});
|
.pointerMove(0, 0, {origin: target});
|
||||||
} else if (eventType === 'mouseleave' || eventType === 'mouseout'
|
} else if (eventType === 'mouseleave' || eventType === 'mouseout'
|
||||||
|| eventType === 'pointerleave' || eventType === 'pointerout') {
|
|| eventType === 'pointerleave' || eventType === 'pointerout') {
|
||||||
@ -219,6 +227,7 @@ async function testEventType(t, eventType, looseCount=false) {
|
|||||||
// Trigger two 'fast' events of the type.
|
// Trigger two 'fast' events of the type.
|
||||||
await applyAction(eventType, target);
|
await applyAction(eventType, target);
|
||||||
await applyAction(eventType, target);
|
await applyAction(eventType, target);
|
||||||
|
await waitForTick();
|
||||||
await new Promise(t.step_func(resolve => {
|
await new Promise(t.step_func(resolve => {
|
||||||
testCounts(t, resolve, looseCount, eventType, initialCount + 2);
|
testCounts(t, resolve, looseCount, eventType, initialCount + 2);
|
||||||
}));
|
}));
|
||||||
@ -260,6 +269,9 @@ async function testEventType(t, eventType, looseCount=false) {
|
|||||||
})).observe({type: 'event', durationThreshold: durationThreshold});
|
})).observe({type: 'event', durationThreshold: durationThreshold});
|
||||||
});
|
});
|
||||||
// Cause a slow event.
|
// Cause a slow event.
|
||||||
let actionPromise = applyAction(eventType, target);
|
await applyAction(eventType, target);
|
||||||
return Promise.all([actionPromise, observerPromise]);
|
|
||||||
|
await waitForTick();
|
||||||
|
|
||||||
|
await observerPromise;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user