https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 341f3f54b111a7dcb76c7f08bc8982634a29fb8b authored by xlai on 19 March 2018, 15:32:35 UTC
Improve wpt testing on OffscreenCanvas convertToBlob
Tip revision: 341f3f5
worklet-reftest.js
// To make sure that we take the snapshot at the right time, we do double
// requestAnimationFrame. In the second frame, we take a screenshot, that makes
// sure that we already have a full frame.
function importWorkletAndTerminateTestAfterAsyncPaint(worklet, code) {
    if (typeof worklet === 'undefined') {
        takeScreenshot();
        return;
    }

    let url;
    if (typeof code === 'object') {
      url = code.url;
    } else {
      const blob = new Blob([code], {type: 'text/javascript'});
      url = URL.createObjectURL(blob);
    }

    worklet.addModule(url).then(function() {
        requestAnimationFrame(function() {
            requestAnimationFrame(function() {
                takeScreenshot();
            });
        });
    });
}
back to top