summaryrefslogtreecommitdiffstats
path: root/devtools/shared/qrcode/tests/chrome
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/shared/qrcode/tests/chrome
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/shared/qrcode/tests/chrome')
-rw-r--r--devtools/shared/qrcode/tests/chrome/chrome.ini5
-rw-r--r--devtools/shared/qrcode/tests/chrome/test_decode.html66
2 files changed, 71 insertions, 0 deletions
diff --git a/devtools/shared/qrcode/tests/chrome/chrome.ini b/devtools/shared/qrcode/tests/chrome/chrome.ini
new file mode 100644
index 0000000000..f73f845e74
--- /dev/null
+++ b/devtools/shared/qrcode/tests/chrome/chrome.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+skip-if = os == 'android'
+tags = devtools
+
+[test_decode.html]
diff --git a/devtools/shared/qrcode/tests/chrome/test_decode.html b/devtools/shared/qrcode/tests/chrome/test_decode.html
new file mode 100644
index 0000000000..cc74de2967
--- /dev/null
+++ b/devtools/shared/qrcode/tests/chrome/test_decode.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Test decoding a simple message
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test decoding a simple message</title>
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+ <script type="application/javascript">
+"use strict";
+
+window.onload = function() {
+
+ const { require } = ChromeUtils.importESModule("resource://devtools/shared/loader/Loader.sys.mjs");
+
+ const QR = require("devtools/shared/qrcode/index");
+
+ SimpleTest.waitForExplicitFinish();
+
+ const testImage =
+ "data:image/gif;base64,R0lGODdhOgA6AIAAAAAAAP///ywAAAAAOgA6AAAC" +
+ "/4yPqcvtD6OctNqLs968+w+G4gKU5nkaKKquLuW+QVy2tAkDTj3rfQts8CRDko" +
+ "+HPPoYRUgy9YsyldDm44mLWhHYZM6W7WaDqyCRGkZDySxpRGw2sqvLt1q5w/fo" +
+ "XyE6vnUQOJUHBlinMGh046V1F5PDqNcoqcgBOWKBKbK2N+aY+Ih49VkmqMcl2l" +
+ "dkhZUK1umE6jZXJ2ZJaujZaRqH4bpb2uZrJxvIt4Ebe9qoYYrJOsw8apz2bCut" +
+ "m9kqDcw52uuImyr5Oh1KXH1jrn2anuunywtODU/o2c6teceW39ZcLFg/fNMo1b" +
+ "t3jVw2dwTPwJq1KYG3gAklCgu37yGxeScYKyiCc+7DR34hPVQiuQ7UhJMagyEb" +
+ "lymmzJk0a9q8iTOnzp0NCgAAOw==";
+
+ (async function () {
+ let result = await QR.decodeFromURI(testImage);
+ is(result, "HELLO", "Decoded data URI result matches");
+ const canvas = await drawToCanvas(testImage);
+ result = QR.decodeFromCanvas(canvas);
+ is(result, "HELLO", "Decoded canvas result matches");
+ })().then(SimpleTest.finish, ok.bind(null, false));
+
+ function drawToCanvas(src) {
+ return new Promise(resolve => {
+ const canvas = document.createElement("canvas");
+ const context = canvas.getContext("2d");
+ const image = new Image();
+
+ image.onload = () => {
+ canvas.width = image.width;
+ canvas.height = image.height;
+ context.drawImage(image, 0, 0);
+ resolve(canvas);
+ };
+ image.src = src;
+ });
+ }
+};
+ </script>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>