Bug 1445780: Part 1 - Allow synthesizeMouse to accept an array of selectors for content in iframes. r=aswan

MozReview-Commit-ID: JCRagaqkkZ6

--HG--
extra : rebase_source : 81d1bd14030b41196c951512c26025e2cf0db9ac
This commit is contained in:
Kris Maglione 2018-03-14 15:08:34 -07:00
Родитель 4f1d6d3f42
Коммит ef176184cb
2 изменённых файлов: 12 добавлений и 2 удалений

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

@ -1010,7 +1010,10 @@ var BrowserTestUtils = {
* @param target
* One of the following:
* - a selector string that identifies the element to target. The syntax is as
* for querySelector.
* for querySelector.
* - An array of selector strings. Each selector after the first
* selects for an element in the iframe specified by the previous
* selector.
* - a CPOW element (for easier test-conversion).
* - a function to be run in the content process that returns the element to
* target
@ -1045,7 +1048,7 @@ var BrowserTestUtils = {
if (typeof target == "function") {
targetFn = target.toString();
target = null;
} else if (typeof target != "string") {
} else if (typeof target != "string" && !Array.isArray(target)) {
cpowObject = target;
target = null;
}

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

@ -25,6 +25,13 @@ addMessageListener("Test:SynthesizeMouse", (message) => {
if (typeof target == "string") {
target = content.document.querySelector(target);
}
else if (Array.isArray(target)) {
let elem = {contentDocument: content.document};
for (let sel of target) {
elem = elem.contentDocument.querySelector(sel);
}
target = elem;
}
else if (typeof data.targetFn == "string") {
let runnablestr = `
(() => {