Bug 1570147 - Add test for drawSnapshot. r=kmag
☠☠ backed out by 1f3fcdc28dfd ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 15 Aug 2019 06:10:21 +0000
changeset 488190 7a24b90275194ce426881b0075c2ea0cd85d9c47
parent 488189 4d528be8bae4048f06fb4c2333a6e852146f25d0
child 488191 b5d442a2f457cc5f9879224879be1775769944e8
push id36437
push userncsoregi@mozilla.com
push dateThu, 15 Aug 2019 19:33:18 +0000
treeherdermozilla-central@44aac6fc3352 [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>