зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1376852 - Port bounds/test_zoom{,_text}.html r=yzen
This commit is contained in:
Родитель
60d852855e
Коммит
1784cc6d45
|
@ -31,6 +31,7 @@ if CONFIG['MOZ_XUL']:
|
|||
TEST_DIRS += ['tests/mochitest']
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += [
|
||||
'tests/browser/bounds/browser.ini',
|
||||
'tests/browser/browser.ini',
|
||||
'tests/browser/e10s/browser.ini',
|
||||
'tests/browser/scroll/browser.ini',
|
||||
|
@ -38,4 +39,4 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
]
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Core", "Disability Access APIs")
|
||||
BUG_COMPONENT = ("Core", "Disability Access APIs")
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[DEFAULT]
|
||||
skip-if = e10s && os == 'win' && release_or_beta
|
||||
support-files =
|
||||
head.js
|
||||
!/accessible/tests/browser/events.js
|
||||
!/accessible/tests/browser/shared-head.js
|
||||
!/accessible/tests/mochitest/*.js
|
||||
!/accessible/tests/mochitest/letters.gif
|
||||
|
||||
[browser_test_zoom.js]
|
||||
[browser_test_zoom_text.js]
|
||||
skip-if = os == 'win' # Bug 1372296
|
|
@ -0,0 +1,68 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../../mochitest/layout.js */
|
||||
|
||||
async function getContentBoundsForDOMElm(browser, id) {
|
||||
return ContentTask.spawn(browser, id, contentId => {
|
||||
this.ok = ok;
|
||||
return getBoundsForDOMElm(contentId);
|
||||
});
|
||||
}
|
||||
|
||||
async function testContentBounds(browser, acc) {
|
||||
let [expectedX, expectedY, expectedWidth, expectedHeight] =
|
||||
await getContentBoundsForDOMElm(browser, getAccessibleDOMNodeID(acc));
|
||||
|
||||
let [x, y, width, height] = getBounds(acc);
|
||||
let prettyAccName = prettyName(acc);
|
||||
is(x, expectedX, "Wrong x coordinate of " + prettyAccName);
|
||||
is(y, expectedY, "Wrong y coordinate of " + prettyAccName);
|
||||
is(width, expectedWidth, "Wrong width of " + prettyAccName);
|
||||
is(height, expectedHeight, "Wrong height of " + prettyAccName);
|
||||
}
|
||||
|
||||
async function runTests(browser, accDoc) {
|
||||
loadFrameScripts(browser, { name: 'layout.js', dir: MOCHITESTS_DIR });
|
||||
|
||||
let p1 = findAccessibleChildByID(accDoc, "p1");
|
||||
let p2 = findAccessibleChildByID(accDoc, "p2");
|
||||
let imgmap = findAccessibleChildByID(accDoc, "imgmap");
|
||||
if (!imgmap.childCount) {
|
||||
// An image map may not be available even after the doc and image load
|
||||
// is complete. We don't recieve any DOM events for this change either,
|
||||
// so we need to wait for a REORDER.
|
||||
await waitForEvent(EVENT_REORDER, "imgmap");
|
||||
}
|
||||
let area = imgmap.firstChild;
|
||||
|
||||
await testContentBounds(browser, p1);
|
||||
await testContentBounds(browser, p2);
|
||||
await testContentBounds(browser, area);
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 2.0);
|
||||
});
|
||||
|
||||
await testContentBounds(browser, p1);
|
||||
await testContentBounds(browser, p2);
|
||||
await testContentBounds(browser, area);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test accessible boundaries when page is zoomed
|
||||
*/
|
||||
addAccessibleTask(`
|
||||
<p id="p1">para 1</p><p id="p2">para 2</p>
|
||||
<map name="atoz_map" id="map">
|
||||
<area id="area1" href="http://mozilla.org"
|
||||
coords=17,0,30,14" alt="mozilla.org" shape="rect">
|
||||
</map>
|
||||
<img id="imgmap" width="447" height="15"
|
||||
usemap="#atoz_map"
|
||||
src="http://example.com/a11y/accessible/tests/mochitest/letters.gif">`,
|
||||
runTests
|
||||
);
|
|
@ -0,0 +1,41 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../../mochitest/layout.js */
|
||||
|
||||
async function runTests(browser, accDoc) {
|
||||
function testTextNode(id) {
|
||||
let hyperTextNode = findAccessibleChildByID(accDoc, id);
|
||||
let textNode = hyperTextNode.firstChild;
|
||||
|
||||
let [x, y, width, height] = getBounds(textNode);
|
||||
testTextBounds(hyperTextNode, 0, -1, [x, y, width, height],
|
||||
COORDTYPE_SCREEN_RELATIVE);
|
||||
}
|
||||
|
||||
loadFrameScripts(browser, { name: 'layout.js', dir: MOCHITESTS_DIR });
|
||||
|
||||
testTextNode("p1");
|
||||
testTextNode("p2");
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 2.0);
|
||||
});
|
||||
|
||||
testTextNode("p1");
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the text range boundary when page is zoomed
|
||||
*/
|
||||
addAccessibleTask(`
|
||||
<p id='p1' style='font-family: monospace;'>Tilimilitryamdiya</p>
|
||||
<p id='p2'>ل</p>`, runTests
|
||||
);
|
|
@ -0,0 +1,16 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
'use strict';
|
||||
|
||||
// Load the shared-head file first.
|
||||
/* import-globals-from ../shared-head.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
'chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js',
|
||||
this);
|
||||
|
||||
// Loading and common.js from accessible/tests/mochitest/ for all tests, as
|
||||
// well as events.js.
|
||||
loadScripts({ name: 'common.js', dir: MOCHITESTS_DIR },
|
||||
{ name: 'layout.js', dir: MOCHITESTS_DIR }, 'events.js');
|
|
@ -8,6 +8,8 @@
|
|||
loadScripts({ name: 'layout.js', dir: MOCHITESTS_DIR });
|
||||
|
||||
async function runTests(browser, accDoc) {
|
||||
loadFrameScripts(browser, { name: 'layout.js', dir: MOCHITESTS_DIR });
|
||||
|
||||
let paragraph = findAccessibleChildByID(accDoc, "paragraph", [nsIAccessibleText]);
|
||||
let offset = 64; // beginning of 4th stanza
|
||||
|
||||
|
@ -18,7 +20,9 @@ async function runTests(browser, accDoc) {
|
|||
COORDTYPE_SCREEN_RELATIVE, docX, docY);
|
||||
testTextPos(paragraph, offset, [x, docY], COORDTYPE_SCREEN_RELATIVE);
|
||||
|
||||
await zoomContent(browser, 2.0);
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 2.0);
|
||||
});
|
||||
|
||||
paragraph = findAccessibleChildByID(accDoc, "paragraph2", [nsIAccessibleText]);
|
||||
offset = 52; // // beginning of 4th stanza
|
||||
|
|
|
@ -4,27 +4,12 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
/* exported zoomContent */
|
||||
|
||||
// Load the shared-head file first.
|
||||
/* import-globals-from ../shared-head.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
'chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js',
|
||||
this);
|
||||
|
||||
async function zoomContent(browser, zoom)
|
||||
{
|
||||
return ContentTask.spawn(browser, zoom, _zoom => {
|
||||
let docShell = content
|
||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIDocShell);
|
||||
let docViewer = docShell.contentViewer;
|
||||
|
||||
docViewer.fullZoom = _zoom;
|
||||
});
|
||||
}
|
||||
|
||||
// Loading and common.js from accessible/tests/mochitest/ for all tests, as
|
||||
// well as events.js.
|
||||
loadScripts({ name: 'common.js', dir: MOCHITESTS_DIR }, 'events.js');
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* import-globals-from events.js */
|
||||
|
||||
/* exported Logger, MOCHITESTS_DIR, invokeSetAttribute, invokeFocus,
|
||||
invokeSetStyle, getAccessibleDOMNodeID,
|
||||
invokeSetStyle, getAccessibleDOMNodeID, getAccessibleTagName,
|
||||
addAccessibleTask, findAccessibleChildByID, isDefunct,
|
||||
CURRENT_CONTENT_DIR, loadScripts, loadFrameScripts, Cc, Cu */
|
||||
|
||||
|
@ -31,6 +31,8 @@ const MOCHITESTS_DIR =
|
|||
const CURRENT_CONTENT_DIR =
|
||||
'http://example.com/browser/accessible/tests/browser/';
|
||||
|
||||
const LOADED_FRAMESCRIPTS = new Map();
|
||||
|
||||
/**
|
||||
* Used to dump debug information.
|
||||
*/
|
||||
|
@ -188,7 +190,17 @@ function loadFrameScripts(browser, ...scripts) {
|
|||
// Script is a object that has { dir, name } format.
|
||||
frameScript = `${script.dir}${script.name}`;
|
||||
}
|
||||
|
||||
let loadedScriptSet = LOADED_FRAMESCRIPTS.get(frameScript);
|
||||
if (!loadedScriptSet) {
|
||||
loadedScriptSet = new WeakSet();
|
||||
LOADED_FRAMESCRIPTS.set(frameScript, loadedScriptSet);
|
||||
} else if (loadedScriptSet.has(browser)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mm.loadFrameScript(frameScript, false, true);
|
||||
loadedScriptSet.add(browser);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,6 +292,19 @@ function isDefunct(accessible) {
|
|||
return defunct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOM tag name for a given accessible.
|
||||
* @param {nsIAccessible} accessible accessible
|
||||
* @return {String?} tag name of associated DOM node, or null.
|
||||
*/
|
||||
function getAccessibleTagName(acc) {
|
||||
try {
|
||||
return acc.attributes.getStringProperty("tag");
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverses the accessible tree starting from a given accessible as a root and
|
||||
* looks for an accessible that matches based on its DOMNode id.
|
||||
|
|
|
@ -4,5 +4,3 @@ support-files =
|
|||
|
||||
[test_list.html]
|
||||
[test_select.html]
|
||||
[test_zoom.html]
|
||||
[test_zoom_text.html]
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Accessible boundaries when page is zoomed</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<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="../events.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../layout.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../browser.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
//gA11yEventDumpToConsole = true;
|
||||
//enableLogging("tree,verbose");
|
||||
function doPreTest()
|
||||
{
|
||||
var tabDocument = currentTabDocument();
|
||||
var imgMap = tabDocument.getElementById("imgmap");
|
||||
waitForImageMap(imgMap, doTest);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
// Bug 746176: Failure of this whole test file on OS X.
|
||||
if (MAC) {
|
||||
todo(false, "Fix bug 746176 on Mac");
|
||||
closeBrowserWindow();
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var tabDocument = currentTabDocument();
|
||||
var p1 = tabDocument.getElementById("p1");
|
||||
var p2 = tabDocument.getElementById("p2");
|
||||
|
||||
var imgMap = tabDocument.getElementById("imgmap");
|
||||
var imgMapAcc = getAccessible(imgMap);
|
||||
var area = imgMapAcc.firstChild;
|
||||
|
||||
testBounds(p1);
|
||||
testBounds(p2);
|
||||
testBounds(area);
|
||||
|
||||
zoomDocument(tabDocument, 2.0);
|
||||
|
||||
testBounds(p1);
|
||||
testBounds(p2);
|
||||
testBounds(area);
|
||||
|
||||
closeBrowserWindow();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var url = "data:text/html,<html><body>";
|
||||
url += "<p id='p1'>para 1</p><p id='p2'>para 2</p>";
|
||||
url += "<map name='atoz_map' id='map'>";
|
||||
url += " <area id='area1' href='http%3A%2F%2Fmozilla.org'";
|
||||
url += " coords=17,0,30,14' alt='mozilla.org' shape='rect'>";
|
||||
url += "</map>";
|
||||
url += "<img id='imgmap' width='447' height='15'";
|
||||
url += " usemap='%23atoz_map'";
|
||||
url += " src='chrome%3A%2F%2Fmochitests%2Fcontent%2Fa11y%2Faccessible%2Fletters.gif'>";
|
||||
url += "</body></html>";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
openBrowserWindow(doPreTest,
|
||||
url,
|
||||
{ left: 0, top: 0, width: 600, height: 600 });
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=650241"
|
||||
title="Location returned by accessibles incorrect when page zoomed">
|
||||
Mozilla Bug 650241
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,77 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The text range boundary when page is zoomed</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<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="../layout.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../browser.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function testTextNode(aDoc, aContainerID)
|
||||
{
|
||||
var hyperTextNode = aDoc.getElementById(aContainerID);
|
||||
var textNode = hyperTextNode.firstChild;
|
||||
|
||||
var [x, y, width, height] = getBounds(textNode);
|
||||
testTextBounds(hyperTextNode, 0, -1, [x, y, width, height],
|
||||
COORDTYPE_SCREEN_RELATIVE);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var tabDocument = currentTabDocument();
|
||||
testTextNode(tabDocument, "p1");
|
||||
testTextNode(tabDocument, "p2");
|
||||
|
||||
zoomDocument(tabDocument, 2.0);
|
||||
|
||||
testTextNode(tabDocument, "p1");
|
||||
|
||||
zoomDocument(tabDocument, 1.0);
|
||||
|
||||
closeBrowserWindow();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var url = "data:text/html,<html>" +
|
||||
"<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>" +
|
||||
"</meta><body>" +
|
||||
"<p id='p1' style='font-family: monospace;'>Tilimilitryamdiya</p>" +
|
||||
"<p id='p2'>ل</p>"
|
||||
"</body></html>";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
openBrowserWindow(doTest,
|
||||
url,
|
||||
{ left: 0, top: 0, width: 600, height: 600 });
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=727942"
|
||||
title="Text range boundaries are incorrect when page is zoomed">
|
||||
Mozilla Bug 727942
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче