Bug 1570147 - Add test for drawSnapshot. r=kmag
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 16 Aug 2019 03:13:21 +0000
changeset 488424 db86b932e8991caf212e135e69d559104925bae1
parent 488423 7ef0d6f34119ec4bb8b6f216c9a205bc93d65475
child 488425 11919743f599ec393c72c61ee7e18ed52b56e435
push id113908
push userccoroiu@mozilla.com
push dateFri, 16 Aug 2019 09:57:53 +0000
treeherdermozilla-inbound@83fad6abe38a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1570147
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1570147 - Add test for drawSnapshot. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D41828
dom/canvas/test/mochitest.ini
dom/canvas/test/test_drawSnapshot.html
--- a/dom/canvas/test/mochitest.ini
+++ b/dom/canvas/test/mochitest.ini
@@ -221,16 +221,18 @@ skip-if = os == "android"
 [test_canvas_strokeStyle_getter.html]
 [test_capture.html]
 support-files = captureStream_common.js
 [test_drawImageIncomplete.html]
 [test_drawImage_document_domain.html]
 [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
 [test_imagebitmap_close.html]
 tags = imagebitmap
 [test_imagebitmap_cropping.html]
 skip-if = android_version >= '17' # bug 1336581
 tags = imagebitmap
new file mode 100644
--- /dev/null
+++ b/dom/canvas/test/test_drawSnapshot.html
@@ -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>