зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1873405 - Test canvas placeholder exemption for pdf.js. r=tjr
Differential Revision: https://phabricator.services.mozilla.com/D197779
This commit is contained in:
Родитель
667283858e
Коммит
4fc0b7ee0f
|
@ -28,3 +28,6 @@ support-files = [
|
|||
["browser_fpiServiceWorkers_fingerprinting.js"]
|
||||
|
||||
["browser_serviceWorker_fingerprinting_webcompat.js"]
|
||||
|
||||
["browser_rfp_canvasplaceholder_pdfjs.js"]
|
||||
support-files = ["file_pdf.pdf"]
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
const PDF_FILE =
|
||||
getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"https://example.com"
|
||||
) + "file_pdf.pdf";
|
||||
|
||||
add_task(async function canvas_placeholder_pdfjs() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["privacy.resistFingerprinting", true]],
|
||||
});
|
||||
|
||||
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PDF_FILE);
|
||||
|
||||
const data = await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
function extractCanvasData() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 10;
|
||||
canvas.height = 10;
|
||||
|
||||
const context = canvas.getContext("2d");
|
||||
|
||||
context.fillStyle = "#332211";
|
||||
context.fillRect(0, 0, 10, 10);
|
||||
|
||||
// Add the canvas element to the document
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
return context.getImageData(0, 0, 10, 10).data;
|
||||
}
|
||||
|
||||
return content.eval(`(${extractCanvasData})()`);
|
||||
});
|
||||
|
||||
is(data.length, 10 * 10 * 4, "correct canvas data size");
|
||||
|
||||
let failure = false;
|
||||
for (var i = 0; i < 10 * 10 * 4; i += 4) {
|
||||
if (
|
||||
data[i] != 0x33 ||
|
||||
data[i + 1] != 0x22 ||
|
||||
data[i + 2] != 0x11 ||
|
||||
data[i + 3] != 0xff
|
||||
) {
|
||||
ok(false, `incorrect data ${data.slice(i, i + 4)} @ ${i}..${i + 3}`);
|
||||
failure = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(!failure, "canvas is correct");
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
%PDF-1.0
|
||||
1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj 2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj 3 0 obj<</Type/Page/MediaBox[0 0 3 3]>>endobj
|
||||
xref
|
||||
0 4
|
||||
0000000000 65535 f
|
||||
0000000010 00000 n
|
||||
0000000053 00000 n
|
||||
0000000102 00000 n
|
||||
trailer<</Size 4/Root 1 0 R>>
|
||||
startxref
|
||||
149
|
||||
%EOF
|
Загрузка…
Ссылка в новой задаче