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:
@@ -1,8 +1,6 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
skip-if = ["os == 'android'"]
|
skip-if = ["os == 'android'"]
|
||||||
support-files = [
|
support-files = [
|
||||||
"image.png",
|
|
||||||
"image-zh.png",
|
|
||||||
"tree_shared.js",
|
"tree_shared.js",
|
||||||
"popup_shared.js",
|
"popup_shared.js",
|
||||||
"window_label_checkbox.xhtml",
|
"window_label_checkbox.xhtml",
|
||||||
@@ -19,15 +17,6 @@ skip-if = ["os == 'linux'"] # Bug 1116215
|
|||||||
|
|
||||||
["test_editor_currentURI.xhtml"]
|
["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_label_checkbox.xhtml"]
|
||||||
|
|
||||||
["test_menubar.xhtml"]
|
["test_menubar.xhtml"]
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ support-files = [
|
|||||||
"audio.wav",
|
"audio.wav",
|
||||||
"audio.ogg",
|
"audio.ogg",
|
||||||
"file_videocontrols_jsdisabled.html",
|
"file_videocontrols_jsdisabled.html",
|
||||||
|
"image.png",
|
||||||
|
"image-zh.png",
|
||||||
"seek_with_sound.ogg",
|
"seek_with_sound.ogg",
|
||||||
"video.ogg",
|
"video.ogg",
|
||||||
"head.js",
|
"head.js",
|
||||||
@@ -33,6 +35,15 @@ support-files = [
|
|||||||
|
|
||||||
["test_bug1654500.html"]
|
["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_mousecapture_area.html"]
|
||||||
|
|
||||||
["test_nac_mutations.html"]
|
["test_nac_mutations.html"]
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Image recognition test</title>
|
<title>Image recognition test</title>
|
||||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script src="head.js"></script>
|
<script type="text/javascript" src="head.js"></script>
|
||||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
<script class="testbody">
|
<script class="testbody">
|
||||||
const { TestUtils } = ChromeUtils.importESModule(
|
const { TestUtils } = SpecialPowers.ChromeUtils.importESModule(
|
||||||
"resource://testing-common/TestUtils.sys.mjs"
|
"resource://testing-common/TestUtils.sys.mjs"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
const img = document.querySelector("#content img");
|
const img = document.querySelector("#content img");
|
||||||
|
|
||||||
info("Recognizing the image text");
|
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.");
|
is(result.length, 2, "Two words were found.");
|
||||||
const mozilla = result.find(r => r.string === "Mozilla");
|
const mozilla = result.find(r => r.string === "Mozilla");
|
||||||
const firefox = result.find(r => r.string === "Firefox");
|
const firefox = result.find(r => r.string === "Firefox");
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Image recognition unsupported</title>
|
<title>Image recognition unsupported</title>
|
||||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script src="head.js"></script>
|
<script type="text/javascript" src="head.js"></script>
|
||||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
info("Recognizing the current image text is not supported on this platform.");
|
info("Recognizing the current image text is not supported on this platform.");
|
||||||
try {
|
try {
|
||||||
await img.recognizeCurrentImageText();
|
await SpecialPowers.wrap(img).recognizeCurrentImageText();
|
||||||
ok(false, "Recognizing the text should not be supported.");
|
ok(false, "Recognizing the text should not be supported.");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ok(error, "Expected unsupported message: " + error.message);
|
ok(error, "Expected unsupported message: " + error.message);
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Image recognition test for Chinese</title>
|
<title>Image recognition test for Chinese</title>
|
||||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script src="head.js"></script>
|
<script type="text/javascript" src="head.js"></script>
|
||||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
info("Recognizing the image text, but not as Chinese");
|
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) {
|
for (const { string } of result) {
|
||||||
isnot(string, "火狐", 'The results are (as expected) incorrect, as Chinese was not set as the language.');
|
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");
|
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.length, 1, "One word was found.");
|
||||||
is(result[0].string, "火狐", "The Chinese characters for Firefox are found.");
|
is(result[0].string, "火狐", "The Chinese characters for Firefox are found.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user