Bug 1859679 - Convert the image recognition tests to plain Mochitests. r=gregtatum

This ensures that we test the IPC part of the implementation.

Differential Revision: https://phabricator.services.mozilla.com/D191666
This commit is contained in:
Andrew McCreight
2023-10-24 19:04:38 +00:00
parent a251a6a419
commit 8a6572b96c
5 changed files with 28 additions and 28 deletions

View File

@@ -1,8 +1,6 @@
[DEFAULT]
skip-if = ["os == 'android'"]
support-files = [
"image.png",
"image-zh.png",
"tree_shared.js",
"popup_shared.js",
"window_label_checkbox.xhtml",
@@ -19,15 +17,6 @@ skip-if = ["os == 'linux'"] # Bug 1116215
["test_editor_currentURI.xhtml"]
["test_image_recognition.html"]
run-if = ["os == 'mac'"] # Mac only feature.
["test_image_recognition_unsupported.html"]
skip-if = ["os == 'mac'"]
["test_image_recognition_zh.html"]
run-if = ["os == 'mac' && os_version != '10.15'"] # Mac only feature, requires > 10.15 to support multilingual results.
["test_label_checkbox.xhtml"]
["test_menubar.xhtml"]

View File

@@ -3,6 +3,8 @@ support-files = [
"audio.wav",
"audio.ogg",
"file_videocontrols_jsdisabled.html",
"image.png",
"image-zh.png",
"seek_with_sound.ogg",
"video.ogg",
"head.js",
@@ -33,6 +35,15 @@ support-files = [
["test_bug1654500.html"]
["test_image_recognition.html"]
run-if = ["os == 'mac'"] # Mac only feature.
["test_image_recognition_unsupported.html"]
skip-if = ["os == 'mac'"]
["test_image_recognition_zh.html"]
run-if = ["os == 'mac' && os_version != '10.15'"] # Mac only feature, requires > 10.15 to support multilingual results.
["test_mousecapture_area.html"]
["test_nac_mutations.html"]

View File

@@ -2,10 +2,10 @@
<html>
<head>
<title>Image recognition test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
@@ -16,7 +16,7 @@
<pre id="test">
<script class="testbody">
const { TestUtils } = ChromeUtils.importESModule(
const { TestUtils } = SpecialPowers.ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
@@ -36,7 +36,7 @@
const img = document.querySelector("#content img");
info("Recognizing the image text");
const result = await img.recognizeCurrentImageText();
const result = await SpecialPowers.wrap(img).recognizeCurrentImageText();
is(result.length, 2, "Two words were found.");
const mozilla = result.find(r => r.string === "Mozilla");
const firefox = result.find(r => r.string === "Firefox");

View File

@@ -2,10 +2,10 @@
<html>
<head>
<title>Image recognition unsupported</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
@@ -24,7 +24,7 @@
info("Recognizing the current image text is not supported on this platform.");
try {
await img.recognizeCurrentImageText();
await SpecialPowers.wrap(img).recognizeCurrentImageText();
ok(false, "Recognizing the text should not be supported.");
} catch (error) {
ok(error, "Expected unsupported message: " + error.message);

View File

@@ -2,10 +2,10 @@
<html>
<head>
<title>Image recognition test for Chinese</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
@@ -29,7 +29,7 @@
info("Recognizing the image text, but not as Chinese");
{
const result = await img.recognizeCurrentImageText();
const result = await SpecialPowers.wrap(img).recognizeCurrentImageText();
for (const { string } of result) {
isnot(string, "火狐", 'The results are (as expected) incorrect, as Chinese was not set as the language.');
}
@@ -40,7 +40,7 @@
info("Recognizing the image text");
{
const result = await img.recognizeCurrentImageText();
const result = await SpecialPowers.wrap(img).recognizeCurrentImageText();
is(result.length, 1, "One word was found.");
is(result[0].string, "火狐", "The Chinese characters for Firefox are found.");
}