mirror of
https://github.com/servo/servo.git
synced 2025-09-05 20:48:22 +01:00
Implement non-visible pipeline and iframe visibility methods
This commit is contained in:
parent
ce88b8ed30
commit
2bff131535
14 changed files with 382 additions and 24 deletions
|
@ -6538,6 +6538,12 @@
|
|||
"url": "/_mozilla/mozilla/mozbrowser/iframe_reload_twice.html"
|
||||
}
|
||||
],
|
||||
"mozilla/mozbrowser/iframe_visibility.html": [
|
||||
{
|
||||
"path": "mozilla/mozbrowser/iframe_visibility.html",
|
||||
"url": "/_mozilla/mozilla/mozbrowser/iframe_visibility.html"
|
||||
}
|
||||
],
|
||||
"mozilla/mozbrowser/mozbrowser_click_fires_openwindow.html": [
|
||||
{
|
||||
"path": "mozilla/mozbrowser/mozbrowser_click_fires_openwindow.html",
|
||||
|
|
6
tests/wpt/mozilla/tests/mozilla/mozbrowser/helper.html
Normal file
6
tests/wpt/mozilla/tests/mozilla/mozbrowser/helper.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<p>test</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,92 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<head>
|
||||
<title>Iframe visibility tests</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var expectedVisibilities = [false, true];
|
||||
var receivedVisibilities = [];
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.mozbrowser = true;
|
||||
iframe.src = "helper.html";
|
||||
|
||||
//Alternate the iframe's visibility and fire mozbrowservisibilitychange
|
||||
iframe.onload = t.step_func(function() {
|
||||
iframe.setVisible(false);
|
||||
iframe.setVisible(true);
|
||||
});
|
||||
|
||||
iframe.addEventListener("mozbrowservisibilitychange", t.step_func(e => {
|
||||
assert_equals(iframe.getVisible(), e.detail.visible);
|
||||
receivedVisibilities.push(e.detail.visible);
|
||||
if (receivedVisibilities.length == expectedVisibilities.length) {
|
||||
assert_array_equals(receivedVisibilities, expectedVisibilities);
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}, "Iframe visibility setter/getter");
|
||||
|
||||
async_test(function(t) {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.mozbrowser = true;
|
||||
iframe.src = "helper.html";
|
||||
var start = null;
|
||||
document.body.appendChild(iframe);
|
||||
iframe.onload = t.step_func(function() {
|
||||
var element = iframe.contentWindow.document.querySelector("p");
|
||||
var animationCompletesAfterResumingVisibility = false;
|
||||
var nonVisibleAnimationStopped = false;
|
||||
element.style.position = 'relative';
|
||||
element.style.right = "0px";
|
||||
var step = t.step_func(function(timestamp) {
|
||||
if (!start) start = timestamp;
|
||||
var progress = timestamp - start;
|
||||
element.style.right = Math.min(progress/5, 100) + "px";
|
||||
if (progress < 500) {
|
||||
iframe.contentWindow.requestAnimationFrame(step);
|
||||
}
|
||||
});
|
||||
|
||||
iframe.setVisible(false);
|
||||
|
||||
iframe.contentWindow.setTimeout(t.step_func(function(){
|
||||
nonVisibleAnimationStopped = element.style.right === '0px';
|
||||
iframe.setVisible(true);
|
||||
}),1000);
|
||||
|
||||
iframe.contentWindow.setTimeout(t.step_func(function(){
|
||||
animationCompletesAfterResumingVisibility = element.style.right === '100px';
|
||||
assert_true(nonVisibleAnimationStopped);
|
||||
assert_true(animationCompletesAfterResumingVisibility);
|
||||
t.done();
|
||||
}),2000);
|
||||
|
||||
iframe.contentWindow.requestAnimationFrame(step);
|
||||
});
|
||||
}, 'Requesting animation frame composites only when frame is visible');
|
||||
|
||||
async_test(function(t) {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "http://web-platform.test:8000/common/blank.html";
|
||||
iframe.mozbrowser = true;
|
||||
iframe.onload = t.step_func(function() {
|
||||
iframe.addEventListener("mozbrowservisibilitychange", t.step_func(function() {
|
||||
var startTime = Date.now();
|
||||
iframe.contentWindow.setTimeout(t.step_func(function() {
|
||||
assert_true(Date.now() - startTime >= 1000);
|
||||
t.done();
|
||||
}), 1);
|
||||
}));
|
||||
iframe.setVisible(false);
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
}, 'Minimum setTimeout of 1s when pipeline is invisible');
|
||||
</script>
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue