Bug 1570147 - Add test for drawSnapshot. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D41828

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-08-16 03:13:21 +00:00
parent 7bf99e1fc3
commit 270a0d1434
2 changed files with 40 additions and 0 deletions

View File

@ -226,6 +226,8 @@ support-files = captureStream_common.js
[test_drawImage_edge_cases.html]
[test_drawWindow.html]
support-files = file_drawWindow_source.html file_drawWindow_common.js
[test_drawSnapshot.html]
support-files = file_drawWindow_source.html file_drawWindow_common.js
[test_imagebitmap.html]
skip-if = android_version == '19' # bug 1336581
tags = imagebitmap

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for drawSnapshot</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/WindowSnapshot.js"></script>
<script type="application/javascript" src="file_drawWindow_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
window.addEventListener("load", runTests);
async function runTests(event) {
let snapshot = async function(context, x, y, width, height, bg) {
let elem = document.getElementById("source");
var rect = new window.DOMRect(x, y, width, height);
let image = await SpecialPowers.snapshotContext(elem, rect, bg);
context.drawImage(image, 0, 0);
}
// Run the tests with the source document in an <iframe> within this
// page, which we expect to have transparency.
await runDrawWindowTests(snapshot, true);
SimpleTest.finish();
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<iframe id="source" src="file_drawWindow_source.html" width="200" height="100"></iframe>
</body>
</html>