mirror of
https://github.com/servo/servo.git
synced 2025-08-23 14:25:33 +01:00
Update web-platform-tests to revision be959408023fe02cf79abe70f6018598a7004a88
This commit is contained in:
parent
a76777b115
commit
761c8bc2a9
171 changed files with 2434 additions and 907 deletions
|
@ -1,46 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<iframe id="testIframe" sandbox="allow-scripts allow-same-origin" style="display:none">
|
||||
<iframe id="testIframe" sandbox="allow-scripts allow-same-origin"
|
||||
style="display:none" src="resources/iframe-listen-orientation-change.html">
|
||||
</iframe>
|
||||
|
||||
<script>
|
||||
var test = async_test("Test subframes receive orientation change events");
|
||||
promise_test(async t => {
|
||||
let orientations = [
|
||||
'portrait-primary',
|
||||
'portrait-secondary',
|
||||
'landscape-primary',
|
||||
'landscape-secondary'
|
||||
];
|
||||
if (screen.orientation.type.includes('portrait')) {
|
||||
orientations = orientations.reverse();
|
||||
}
|
||||
const messageWatcher = new EventWatcher(t, window, "message");
|
||||
|
||||
var orientations = [
|
||||
'portrait-primary',
|
||||
'portrait-secondary',
|
||||
'landscape-primary',
|
||||
'landscape-secondary'
|
||||
];
|
||||
|
||||
var currentIndex = orientations.indexOf(window.screen.orientation.type);
|
||||
var eventsReceived = 0;
|
||||
|
||||
function getNextIndex() {
|
||||
return (currentIndex + 1) % orientations.length;
|
||||
}
|
||||
|
||||
function changeOrientation() {
|
||||
screen.orientation.lock(orientations[getNextIndex()]).then(function () {}, function () {});
|
||||
currentIndex = getNextIndex();
|
||||
}
|
||||
|
||||
window.onmessage = test.step_func(function (ev) {
|
||||
assert_equals(ev.data, orientations[currentIndex], "subframe receives orientation change event");
|
||||
++eventsReceived;
|
||||
if (eventsReceived < orientations.length)
|
||||
changeOrientation()
|
||||
else
|
||||
test.done();
|
||||
});
|
||||
|
||||
var testIframe = document.getElementById("testIframe");
|
||||
testIframe.src = "resources/iframe-listen-orientation-change.html";
|
||||
testIframe.onload = changeOrientation;
|
||||
for (const orientation of orientations) {
|
||||
await screen.orientation.lock(orientation);
|
||||
const message = await messageWatcher.wait_for("message");
|
||||
assert_equals(message.data, orientation, "subframe receives orientation change event");
|
||||
}
|
||||
screen.orientation.unlock();
|
||||
}, "Test subframes receive orientation change events");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue