Bug 1446671 - Convert mochitest/textcaret/test_browserui.xul test into a browser test. r=yzen, gijs

This commit is contained in:
Alexander Surkov 2018-04-11 16:13:30 -04:00
Родитель 4119735d14
Коммит a64f999c41
5 изменённых файлов: 59 добавлений и 68 удалений

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

@ -7,5 +7,6 @@ support-files =
[browser_test_docload.js]
skip-if = e10s
[browser_test_textcaret.js]
[browser_test_focus_browserui.js]
[browser_test_focus_dialog.js]

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

@ -0,0 +1,54 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Caret move events checker.
*/
function caretMoveChecker(target, caretOffset) {
return function(event) {
let cmEvent = event.QueryInterface(nsIAccessibleCaretMoveEvent);
return cmEvent.accessible == getAccessible(target) && cmEvent.caretOffset == caretOffset;
};
}
async function checkURLBarCaretEvents() {
let url = "about:mozilla";
let onDocLoad = waitForEvent(
EVENT_DOCUMENT_LOAD_COMPLETE,
event => {
try { return event.accessible.QueryInterface(nsIAccessibleDocument).URL == url; }
catch(e) { return false; }
}
);
let [ newWin ] = await Promise.all([
BrowserTestUtils.openNewBrowserWindow({ url }),
onDocLoad
]);
let urlbarInputEl = newWin.document.getElementById("urlbar").inputField;
let urlbarInput = getAccessible(urlbarInputEl, [ nsIAccessibleText ]);
let onCaretMove = waitForEvents([
[ EVENT_TEXT_CARET_MOVED, caretMoveChecker(urlbarInput, url.length) ],
[ EVENT_FOCUS, urlbarInput ]
]);
urlbarInput.caretOffset = -1;
await onCaretMove;
ok(true, "Caret move in URL bar #1");
onCaretMove = waitForEvent(
EVENT_TEXT_CARET_MOVED, caretMoveChecker(urlbarInput, 0)
);
urlbarInput.caretOffset = 0;
await onCaretMove;
ok(true, "Caret move in URL bar #2");
await BrowserTestUtils.closeWindow(newWin);
}
add_task(checkURLBarCaretEvents);

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

@ -2,5 +2,4 @@
support-files =
!/accessible/tests/mochitest/*.js
[test_browserui.xul]
[test_general.html]

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

@ -1,67 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Accessibility Caret Offset Test.">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../states.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript"
src="../browser.js"></script>
<script type="application/javascript">
<![CDATA[
////////////////////////////////////////////////////////////////////////////
// Tests
gA11yEventDumpToConsole = true; // debug
//enableLogging("tree,verbose");
var gQueue = null;
function doTests()
{
gQueue = new eventQueue();
gQueue.push(new setCaretOffset(urlbarInput(), -1, urlbarInput()));
gQueue.push(new setCaretOffset(urlbarInput(), 0));
gQueue.onFinish = function()
{
closeBrowserWindow();
}
gQueue.invoke();
}
SimpleTest.waitForExplicitFinish();
openBrowserWindow(doTests, "about:mozilla");
]]>
</script>
<vbox flex="1" style="overflow: auto;">
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=723833"
title="IAccessibleText::setCaretOffset on location or search bar causes focus to jump">
Bug 723833
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</vbox>
</window>

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

@ -700,6 +700,10 @@ var BrowserTestUtils = {
features += `,${remoteState}`;
}
if (options.url) {
argString.data = options.url;
}
let win = Services.ww.openWindow(
opener, Services.prefs.getCharPref("browser.chromeURL"), "_blank",
features, argString);