Last active
November 28, 2016 14:28
-
-
Save daleharvey/8e2ef60cff94981ef457e4bd31414ba3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeTestURL({ body }) { | |
const url = new URL(defaultURL); | |
url.searchParams.set("Content-Type", "text/html; charset=utf-8"); | |
url.searchParams.set("body", encodeURIComponent(body)); | |
return url.href; | |
} | |
function getIconColor(window, icon) { | |
return new Promise(resolve => { | |
const canvas = window.document.createElement('canvas'); | |
const ctx = canvas.getContext("2d"); | |
// The line above causes | |
// | |
//5 INFO TEST-UNEXPECTED-FAIL | dom/manifest/test/browser_ManifestIcons_browserFetchIcon.js | Uncaught exception - at chrome://mochitests/content/browser/dom/manifest/test/browser_ManifestIcons_browserFetchIcon.js:35 - Error: cross-process JS call failed | |
//Stack trace: | |
// getIconColor/<@chrome://mochitests/content/browser/dom/manifest/test/browser_ManifestIcons_browserFetchIcon.js:35:17 | |
const image = new Image(); | |
image.onload = function() { | |
ctx.drawImage(image, 0, 0); | |
resolve(ctx.getImageData(0, 0, 1, 1).data); | |
}; | |
image.src = icon; | |
}); | |
} | |
add_task(function*() { | |
const runningTests = tests | |
.map(test => ({gBrowser, test, url: makeTestURL(test)})) | |
.map( | |
tabOptions => BrowserTestUtils.withNewTab(tabOptions, function*(browser) { | |
const manifest = yield ManifestObtainer.browserObtainManifest(browser); | |
const icon = yield ManifestIcons.browserFetchIcon(browser, manifest, 100); | |
const data = yield getIconColor(browser.contentWindow, icon); | |
ok(true, 'yay'); | |
}) | |
); | |
yield Promise.all(runningTests); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment