Bug 1456770 [wpt PR 10630] - Ensure event handlers are not garbage collected in ImageBitmap tests on WebKit., a=testonly
authorMs2ger <Ms2ger@gmail.com>
Tue, 01 May 2018 14:34:07 +0000
changeset 472647 e287052716555424772dc1217726455db1477014
parent 472646 f38318e50a9558108306b204d25b3a29779526e6
child 472648 b974f399050e615673c4ff281223bbafd235ea9d
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1456770, 10630
milestone61.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 1456770 [wpt PR 10630] - Ensure event handlers are not garbage collected in ImageBitmap tests on WebKit., a=testonly Automatic update from web-platform-testsEnsure event handlers are not garbage collected in ImageBitmap tests on WebKit. -- wpt-commits: 170bf8330e41fd6ba0af816dd6fca4816cbf8d8d wpt-pr: 10630
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/2dcontext/imagebitmap/common.sub.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -398830,17 +398830,17 @@
    "ced9462ac91d311bf915e17cd784ffc731cfb333",
    "testharness"
   ],
   "2dcontext/image-smoothing/imagesmoothing.html": [
    "a50b997a4c738f68360f4aa450e1ea7f12687770",
    "testharness"
   ],
   "2dcontext/imagebitmap/common.sub.js": [
-   "03f7c67a1001cdaf46dc5bccb4846ba7d6ab50cd",
+   "5da74cfd37ef072aa5b50c9a5fb658754984216b",
    "support"
   ],
   "2dcontext/imagebitmap/createImageBitmap-drawImage.html": [
    "adef50e6043c6ecb80bdc4a6b7f9d9a599a80656",
    "testharness"
   ],
   "2dcontext/imagebitmap/createImageBitmap-invalid-args.html": [
    "ea323d1c0adfa41e6f5c56be2006a4cd178c470d",
--- a/testing/web-platform/tests/2dcontext/imagebitmap/common.sub.js
+++ b/testing/web-platform/tests/2dcontext/imagebitmap/common.sub.js
@@ -27,45 +27,53 @@ function makeOffscreenCanvas() {
         testCtx.fillStyle = "rgb(0, 0, 255)";
         testCtx.fillRect(0, 10, 10, 10);
         testCtx.fillStyle = "rgb(0, 0, 0)";
         testCtx.fillRect(10, 10, 10, 10);
         resolve(canvas);
     });
 }
 
+var imageBitmapVideoPromise = new Promise(function(resolve, reject) {
+    var video = document.createElement("video");
+    video.oncanplaythrough = function() {
+        resolve(video);
+    };
+    video.onerror = reject;
+    video.src = getVideoURI("/images/pattern");
+
+    // Prevent WebKit from garbage collecting event handlers.
+    window._video = video;
+});
+
 function makeVideo() {
-    return new Promise(function(resolve, reject) {
-        var video = document.createElement("video");
-        video.oncanplaythrough = function() {
-            resolve(video);
-        };
-        video.onerror = reject;
-        video.src = getVideoURI("/images/pattern");
+    return imageBitmapVideoPromise;
+}
+
+var imageBitmapDataUrlVideoPromise = fetch(getVideoURI("/images/pattern"))
+    .then(response => Promise.all([response.headers.get("Content-Type"), response.arrayBuffer()]))
+    .then(([type, data]) => {
+        return new Promise(function(resolve, reject) {
+            var video = document.createElement("video");
+            video.oncanplaythrough = function() {
+                resolve(video);
+            };
+            video.onerror = reject;
+
+            var encoded = btoa(String.fromCodePoint(...new Uint8Array(data)));
+            var dataUrl = `data:${type};base64,${encoded}`;
+            video.src = dataUrl;
+
+            // Prevent WebKit from garbage collecting event handlers.
+            window._dataVideo = video;
+        });
     });
-}
 
 function makeDataUrlVideo() {
-    const toDataUrl = (type, buffer) => {
-        const encoded = btoa(String.fromCodePoint(...new Uint8Array(buffer)));
-        return `data:${type};base64,${encoded}`
-    };
-
-    return fetch(getVideoURI("/images/pattern"))
-        .then(response => Promise.all([response.headers.get("Content-Type"), response.arrayBuffer()]))
-        .then(([type, data]) => {
-            return new Promise(function(resolve, reject) {
-                var video = document.createElement("video");
-                video.oncanplaythrough = function() {
-                    resolve(video);
-                };
-                video.onerror = reject;
-                video.src = toDataUrl(type, data);
-            });
-        });
+    return imageBitmapDataUrlVideoPromise;
 }
 
 function makeMakeHTMLImage(src) {
     return function() {
         return new Promise((resolve, reject) => {
             var img = new Image();
             img.onload = function() {
                 resolve(img);