зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1481024: Stop relying on lexical variables being available across frame scripts. r=yzen
The accessibility tests currently rely, in many places, on lexical variables defined in global frame scripts being available to other non-global frame scripts. While that is currently the case, it will stop being so soon. And, while the simplest solution would be to define them as properties on the frame message manager by using `var` rather than `let`, storing references to the current content window in a frame script scope is unsafe at best, and should be avoided at all costs. MozReview-Commit-ID: 4FCGtLgcFzl --HG-- extra : rebase_source : d21206c9f119ca0ce61f9956f84a2e2d11484bca
This commit is contained in:
Родитель
1c0025e0de
Коммит
637cac1ea7
|
@ -17,7 +17,7 @@ async function testScaledBounds(browser, accDoc, scale, id, type = "object") {
|
|||
getRangeExtents(acc, 0, -1, COORDTYPE_SCREEN_RELATIVE) : getBounds(acc);
|
||||
|
||||
await ContentTask.spawn(browser, scale, _scale => {
|
||||
setResolution(document, _scale);
|
||||
setResolution(content.document, _scale);
|
||||
});
|
||||
|
||||
let [scaledX, scaledY, scaledWidth, scaledHeight] = type == "text" ?
|
||||
|
@ -30,7 +30,7 @@ async function testScaledBounds(browser, accDoc, scale, id, type = "object") {
|
|||
isWithin(scaledY - docY, (y - docY) * scale, 2, "Wrong scaled y of " + name);
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
setResolution(document, 1.0);
|
||||
setResolution(content.document, 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ async function runTests(browser, accDoc) {
|
|||
await testContentBounds(browser, area);
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 2.0);
|
||||
zoomDocument(content.document, 2.0);
|
||||
});
|
||||
|
||||
await testContentBounds(browser, p1);
|
||||
|
|
|
@ -36,13 +36,13 @@ async function runTests(browser, accDoc) {
|
|||
await testEmptyInputNode("i1");
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 2.0);
|
||||
zoomDocument(content.document, 2.0);
|
||||
});
|
||||
|
||||
await testTextNode("p1");
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 1.0);
|
||||
zoomDocument(content.document, 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ add_task(async function() {
|
|||
contentConsumersChanged =
|
||||
ContentTask.spawn(browser, {}, a11yConsumersChangedPromise);
|
||||
// Add a new reference to the a11y service inside the content process.
|
||||
loadFrameScripts(browser, `let accService = Components.classes[
|
||||
loadFrameScripts(browser, `var accService = Components.classes[
|
||||
'@mozilla.org/accessibilityService;1'].getService(
|
||||
Components.interfaces.nsIAccessibilityService);`);
|
||||
await contentConsumersChanged.then(data => Assert.deepEqual(data, {
|
||||
|
|
|
@ -334,7 +334,7 @@ async function testAttrRule(browser, target, rule, expected) {
|
|||
let [event] = await contentSpawnMutation(browser, {
|
||||
expected: [recreated ? [EVENT_REORDER, parent] : [EVENT_TEXT_INSERTED, id]]
|
||||
}, ([contentId, contentAttr]) =>
|
||||
document.getElementById(contentId).removeAttribute(contentAttr), [id, attr]);
|
||||
content.document.getElementById(contentId).removeAttribute(contentAttr), [id, attr]);
|
||||
|
||||
// Update accessible just in case it is now defunct.
|
||||
target.acc = findAccessibleChildByID(event.accessible, id);
|
||||
|
@ -362,7 +362,7 @@ async function testElmRule(browser, target, rule, expected) {
|
|||
testName(acc, expected);
|
||||
let [event] = await contentSpawnMutation(browser, {
|
||||
expected: [[EVENT_REORDER, isSibling ? parent : id]]
|
||||
}, contentElm => document.querySelector(`${contentElm}`).remove(), elm);
|
||||
}, contentElm => content.document.querySelector(`${contentElm}`).remove(), elm);
|
||||
|
||||
// Update accessible just in case it is now defunct.
|
||||
target.acc = findAccessibleChildByID(event.accessible, id);
|
||||
|
@ -387,7 +387,7 @@ async function testSubtreeRule(browser, target, rule, expected) {
|
|||
let [event] = await contentSpawnMutation(browser, {
|
||||
expected: [[EVENT_REORDER, id]]
|
||||
}, contentId => {
|
||||
let elm = document.getElementById(contentId);
|
||||
let elm = content.document.getElementById(contentId);
|
||||
while (elm.firstChild) {
|
||||
elm.firstChild.remove();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ addAccessibleTask(`
|
|||
async function(browser, accDoc) {
|
||||
let onVCChanged = waitForEvent(EVENT_VIRTUALCURSOR_CHANGED, accDoc);
|
||||
await ContentTask.spawn(browser, null, () => {
|
||||
let vc = getAccessible(document, nsIAccessibleDocument).virtualCursor;
|
||||
let vc = getAccessible(content.document, Ci.nsIAccessibleDocument).virtualCursor;
|
||||
vc.position = getAccessible("p1");
|
||||
});
|
||||
|
||||
|
@ -23,8 +23,8 @@ addAccessibleTask(`
|
|||
|
||||
onVCChanged = waitForEvent(EVENT_VIRTUALCURSOR_CHANGED, accDoc);
|
||||
await ContentTask.spawn(browser, null, () => {
|
||||
let vc = getAccessible(document, nsIAccessibleDocument).virtualCursor;
|
||||
vc.moveNextByText(nsIAccessiblePivot.CHAR_BOUNDARY);
|
||||
let vc = getAccessible(content.document, Ci.nsIAccessibleDocument).virtualCursor;
|
||||
vc.moveNextByText(Ci.nsIAccessiblePivot.CHAR_BOUNDARY);
|
||||
});
|
||||
vccEvent = (await onVCChanged).QueryInterface(
|
||||
nsIAccessibleVirtualCursorChangeEvent);
|
||||
|
@ -35,7 +35,7 @@ addAccessibleTask(`
|
|||
|
||||
onVCChanged = waitForEvent(EVENT_VIRTUALCURSOR_CHANGED, accDoc);
|
||||
await ContentTask.spawn(browser, null, () => {
|
||||
let vc = getAccessible(document, nsIAccessibleDocument).virtualCursor;
|
||||
let vc = getAccessible(content.document, Ci.nsIAccessibleDocument).virtualCursor;
|
||||
vc.position = getAccessible("input1");
|
||||
});
|
||||
vccEvent = (await onVCChanged).QueryInterface(
|
||||
|
|
|
@ -21,7 +21,7 @@ async function runTests(browser, accDoc) {
|
|||
testTextPos(paragraph, offset, [x, docY], COORDTYPE_SCREEN_RELATIVE);
|
||||
|
||||
await ContentTask.spawn(browser, {}, () => {
|
||||
zoomDocument(document, 2.0);
|
||||
zoomDocument(content.document, 2.0);
|
||||
});
|
||||
|
||||
paragraph = findAccessibleChildByID(accDoc, "paragraph2", [nsIAccessibleText]);
|
||||
|
|
|
@ -16,7 +16,7 @@ addAccessibleTask(`<ul id="container"><li id="a">Test</li></ul>`,
|
|||
|
||||
await contentSpawnMutation(browser, NO_MOVE, function() {
|
||||
// aria-own ordinal child in place, should be a no-op.
|
||||
document.getElementById("container").setAttribute("aria-owns", "a");
|
||||
content.document.getElementById("container").setAttribute("aria-owns", "a");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, ["a"]);
|
||||
|
@ -32,10 +32,10 @@ addAccessibleTask(`<ul id="container"><li id="a">Test</li></ul>`,
|
|||
testChildrenIds(containerAcc, ["a"]);
|
||||
|
||||
await contentSpawnMutation(browser, MOVE, function() {
|
||||
let container = document.getElementById("container");
|
||||
let container = content.document.getElementById("container");
|
||||
container.setAttribute("aria-owns", "a");
|
||||
|
||||
let aa = document.createElement("li");
|
||||
let aa = content.document.createElement("li");
|
||||
aa.id = "aa";
|
||||
container.appendChild(aa);
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ addAccessibleTask(`<ul id="container"><li id="a">Test</li></ul>`,
|
|||
testChildrenIds(containerAcc, ["aa", "a"]);
|
||||
|
||||
await contentSpawnMutation(browser, MOVE, function() {
|
||||
document.getElementById("container").removeAttribute("aria-owns");
|
||||
content.document.getElementById("container").removeAttribute("aria-owns");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, ["a", "aa"]);
|
||||
|
@ -59,7 +59,7 @@ addAccessibleTask(`<ul id="container" aria-owns="a"><li id="a">Test</li></ul>`,
|
|||
|
||||
await contentSpawnMutation(browser, NO_MOVE, function() {
|
||||
// remove aria-owned child that is already ordinal, should be no-op.
|
||||
document.getElementById("container").removeAttribute("aria-owns");
|
||||
content.document.getElementById("container").removeAttribute("aria-owns");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, ["a"]);
|
||||
|
@ -79,7 +79,7 @@ addAccessibleTask(`
|
|||
testChildrenIds(containerAcc, []);
|
||||
|
||||
await contentSpawnMutation(browser, NO_MOVE, function() {
|
||||
document.getElementById("container").setAttribute("aria-owns", "a");
|
||||
content.document.getElementById("container").setAttribute("aria-owns", "a");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, []);
|
||||
|
@ -151,7 +151,7 @@ addAccessibleTask(`
|
|||
testChildrenIds(containerAcc.firstChild, ["a", "b", "c"]);
|
||||
|
||||
await contentSpawnMutation(browser, NO_MOVE, function() {
|
||||
document.getElementById("container").setAttribute("aria-owns", "a c b");
|
||||
content.document.getElementById("container").setAttribute("aria-owns", "a c b");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc.firstChild, ["a", "b", "c"]);
|
||||
|
@ -183,7 +183,7 @@ addAccessibleTask(`
|
|||
|
||||
await contentSpawnMutation(browser, waitfor, function() {
|
||||
// Put same id twice in aria-owns
|
||||
document.getElementById("two").setAttribute("aria-owns", "a a");
|
||||
content.document.getElementById("two").setAttribute("aria-owns", "a a");
|
||||
});
|
||||
|
||||
testChildrenIds(one, ["b", "c"]);
|
||||
|
@ -192,7 +192,7 @@ addAccessibleTask(`
|
|||
await contentSpawnMutation(browser, waitfor, function() {
|
||||
// If the previous double-id aria-owns worked correctly, we should
|
||||
// be in a good state and all is fine..
|
||||
document.getElementById("two").setAttribute("aria-owns", "a b");
|
||||
content.document.getElementById("two").setAttribute("aria-owns", "a b");
|
||||
});
|
||||
|
||||
testChildrenIds(one, ["c"]);
|
||||
|
@ -209,10 +209,10 @@ addAccessibleTask(`<div id="a"></div><div id="b"></div>`,
|
|||
};
|
||||
|
||||
await contentSpawnMutation(browser, waitFor, function() {
|
||||
document.documentElement.style.display = "none";
|
||||
document.documentElement.getBoundingClientRect();
|
||||
document.body.setAttribute("aria-owns", "b a");
|
||||
document.documentElement.remove();
|
||||
content.document.documentElement.style.display = "none";
|
||||
content.document.documentElement.getBoundingClientRect();
|
||||
content.document.body.setAttribute("aria-owns", "b a");
|
||||
content.document.documentElement.remove();
|
||||
});
|
||||
|
||||
testChildrenIds(accDoc, []);
|
||||
|
@ -228,24 +228,24 @@ addAccessibleTask(`<div id="container"><div id="a">Hello</div></div>
|
|||
testChildrenIds(containerAcc, ["a"]);
|
||||
|
||||
await contentSpawnMutation(browser, MOVE, function() {
|
||||
document.getElementById("container").setAttribute("aria-owns", "c");
|
||||
content.document.getElementById("container").setAttribute("aria-owns", "c");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, ["a", "c"]);
|
||||
|
||||
await contentSpawnMutation(browser, MOVE, function() {
|
||||
let span = document.createElement("span");
|
||||
document.getElementById("container").appendChild(span);
|
||||
let span = content.document.createElement("span");
|
||||
content.document.getElementById("container").appendChild(span);
|
||||
|
||||
let b = document.createElement("div");
|
||||
let b = content.document.createElement("div");
|
||||
b.id = "b";
|
||||
document.getElementById("container").appendChild(b);
|
||||
content.document.getElementById("container").appendChild(b);
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, ["a", "b", "c"]);
|
||||
|
||||
await contentSpawnMutation(browser, MOVE, function() {
|
||||
document.getElementById("container").setAttribute("aria-owns", "c d");
|
||||
content.document.getElementById("container").setAttribute("aria-owns", "c d");
|
||||
});
|
||||
|
||||
testChildrenIds(containerAcc, ["a", "b", "c", "d"]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче