Backed out changeset 4035fee4dd33 (bug 1538042) for Mochitest failures in toolkit/components/windowcreator/test/test_nsFind.html

This commit is contained in:
Dorel Luca 2019-09-05 12:21:18 +03:00
Родитель 98c51594e4
Коммит 97d9dbf374
2 изменённых файлов: 53 добавлений и 89 удалений

Просмотреть файл

@ -122,14 +122,6 @@ let runTests = t.step_func_done(function() {
input.value = "foo";
document.documentElement.appendChild(input);
}, "Native anonymous content isn't exposed in window.find");
testFindable(false, "\0", `
�
`);
testFindable(true, "\0", function(document) {
document.documentElement.appendChild(document.createTextNode("\0"));
}, "Inserted null characters are findable");
});
window.onload = function() {

Просмотреть файл

@ -8,23 +8,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=450048
<title>Test for nsFind::Find()</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
<p id="display">This is the text to search i<b>n&shy;t</b>o</p>
<p id="quotes">"straight" and &ldquo;curly&rdquo; and &lsquo;didn't&rsquo; and 'doesn&rsquo;t'</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 450048 **/
SimpleTest.waitForExplicitFinish();
async function runTests() {
// Check nsFind class and its nsIFind interface.
// Inject some text that we'll search for later.
const INJECTED_NULL_TEXT = "injected null\0";
const nullcharsinjected = document.getElementById("nullcharsinjected");
const nulltextnode = document.createTextNode(INJECTED_NULL_TEXT);
nullcharsinjected.appendChild(nulltextnode);
await new Promise(resolve => window.requestAnimationFrame(resolve));
var rf = SpecialPowers.Cc["@mozilla.org/embedcomp/rangefind;1"]
.getService(SpecialPowers.Ci.nsIFind);
@ -35,6 +33,48 @@ async function runTests() {
var startPt = searchRange;
var endPt = searchRange;
// Check |null| detection on |aSearchRange| parameter.
try {
rf.Find("", null, startPt, endPt);
ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
ok(true, null);
} else {
throw wrappedError;
}
}
// Check |null| detection on |aStartPoint| parameter.
try {
rf.Find("", searchRange, null, endPt);
ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
ok(true, null);
} else {
throw wrappedError;
}
}
// Check |null| detection on |aEndPoint| parameter.
try {
rf.Find("", searchRange, startPt, null);
ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
ok(true, null);
} else {
throw wrappedError;
}
}
var searchValue, retRange;
rf.findBackwards = false;
@ -84,6 +124,7 @@ async function runTests() {
retRange = rf.Find(searchValue, searchRange, startPt, endPt);
ok(retRange, "\"" + searchValue + "\" not found (backward)");
// Curly quotes and straight quotes should match.
rf.caseSensitive = false;
@ -97,11 +138,11 @@ async function runTests() {
}
function assertFound(node, value) {
ok(find(node, value), "\"" + value + "\" should be found");
ok(find(node, value), "\"" + value + "\" not found");
}
function assertNotFound(node, value) {
ok(!find(node, value), "\"" + value + "\" should not be found");
ok(!find(node, value), "\"" + value + "\" found");
}
var quotes = document.getElementById("quotes");
@ -180,76 +221,7 @@ async function runTests() {
assertFound(quotes, "'doesn\u2019t'");
assertNotFound(quotes, "'doesn\u2018t'");
assertNotFound(quotes, "'doesn't'");
// Embedded strings containing null characters can't be found, because
// the HTML parser converts them to \ufffd, which is the replacement
// character.
const nullcharsnative = document.getElementById("nullcharsnative");
assertFound(nullcharsnative, "native null\ufffd");
// Injected strings containing null characters can be found.
assertFound(nullcharsinjected, INJECTED_NULL_TEXT);
// Do these test at the end since they trigger failure screenshots in
// the test harness, and we want as much information as possible about
// any OTHER tests that may have already failed.
// Check |null| detection on |aSearchRange| parameter.
try {
rf.Find("", null, startPt, endPt);
ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
ok(true, null);
} else {
throw wrappedError;
}
}
// Check |null| detection on |aStartPoint| parameter.
try {
rf.Find("", searchRange, null, endPt);
ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
ok(true, null);
} else {
throw wrappedError;
}
}
// Check |null| detection on |aEndPoint| parameter.
try {
rf.Find("", searchRange, startPt, null);
ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
} catch (e) {
let wrappedError = SpecialPowers.wrap(e);
if (wrappedError.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
ok(true, null);
} else {
throw wrappedError;
}
}
SimpleTest.finish();
}
</script>
</head>
<body onload="runTests()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
<p id="display">This is the text to search i<b>n&shy;t</b>o</p>
<p id="quotes">"straight" and &ldquo;curly&rdquo; and &lsquo;didn't&rsquo; and 'doesn&rsquo;t'</p>
<p id="nullcharsnative">native null&#0;</p>
<p id="nullcharsinjected"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>