mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1084412 - marionette.findElements returns immediately when searchTimeout is set, r=AutomatedTester
--HG-- extra : rebase_source : bd89e6209edaa5a4a5f7552dc548e0db120c88e8
This commit is contained in:
parent
4b25c6ba5a
commit
fc5f796638
@ -122,7 +122,7 @@ class TestElements(MarionetteTestCase):
|
||||
self.marionette.set_search_timeout(0)
|
||||
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
|
||||
|
||||
def test_timeout(self):
|
||||
def test_timeout_element(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
button = self.marionette.find_element("id", "createDivButton")
|
||||
@ -131,6 +131,15 @@ class TestElements(MarionetteTestCase):
|
||||
self.assertTrue(True, self.marionette.set_search_timeout(8000))
|
||||
self.assertEqual(HTMLElement, type(self.marionette.find_element(By.ID, "newDiv")))
|
||||
|
||||
def test_timeout_elements(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
button = self.marionette.find_element("id", "createDivButton")
|
||||
button.click()
|
||||
self.assertEqual(len(self.marionette.find_elements(By.ID, "newDiv")), 0)
|
||||
self.assertTrue(True, self.marionette.set_search_timeout(8000))
|
||||
self.assertEqual(len(self.marionette.find_elements(By.ID, "newDiv")), 1)
|
||||
|
||||
def test_css_selector_scope_doesnt_start_at_rootnode(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
|
@ -297,30 +297,22 @@ ElementManager.prototype = {
|
||||
}
|
||||
let found = all ? this.findElements(values.using, values.value, win.document, startNode) :
|
||||
this.findElement(values.using, values.value, win.document, startNode);
|
||||
if (found) {
|
||||
let type = Object.prototype.toString.call(found);
|
||||
if ((type == '[object Array]') || (type == '[object HTMLCollection]') || (type == '[object NodeList]')) {
|
||||
let ids = []
|
||||
for (let i = 0 ; i < found.length ; i++) {
|
||||
ids.push(this.addToKnownElements(found[i]));
|
||||
}
|
||||
on_success(ids, command_id);
|
||||
}
|
||||
else {
|
||||
let id = this.addToKnownElements(found);
|
||||
on_success({'ELEMENT':id}, command_id);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
let type = Object.prototype.toString.call(found);
|
||||
let isArrayLike = ((type == '[object Array]') || (type == '[object HTMLCollection]') || (type == '[object NodeList]'));
|
||||
if (found == null || (isArrayLike && found.length <= 0)) {
|
||||
if (!searchTimeout || new Date().getTime() - startTime > searchTimeout) {
|
||||
// Format message depending on strategy if necessary
|
||||
let message = "Unable to locate element: " + values.value;
|
||||
if (values.using == ANON) {
|
||||
message = "Unable to locate anonymous children";
|
||||
} else if (values.using == ANON_ATTRIBUTE) {
|
||||
message = "Unable to locate anonymous element: " + JSON.stringify(values.value);
|
||||
if (all) {
|
||||
on_success([], command_id); // findElements should return empty list
|
||||
} else {
|
||||
// Format message depending on strategy if necessary
|
||||
let message = "Unable to locate element: " + values.value;
|
||||
if (values.using == ANON) {
|
||||
message = "Unable to locate anonymous children";
|
||||
} else if (values.using == ANON_ATTRIBUTE) {
|
||||
message = "Unable to locate anonymous element: " + JSON.stringify(values.value);
|
||||
}
|
||||
on_error(message, 7, null, command_id);
|
||||
}
|
||||
on_error(message, 7, null, command_id);
|
||||
} else {
|
||||
values.time = startTime;
|
||||
this.timer.initWithCallback(this.find.bind(this, win, values,
|
||||
@ -330,6 +322,18 @@ ElementManager.prototype = {
|
||||
100,
|
||||
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
} else {
|
||||
if (isArrayLike) {
|
||||
let ids = []
|
||||
for (let i = 0 ; i < found.length ; i++) {
|
||||
ids.push(this.addToKnownElements(found[i]));
|
||||
}
|
||||
on_success(ids, command_id);
|
||||
} else {
|
||||
let id = this.addToKnownElements(found);
|
||||
on_success({'ELEMENT':id}, command_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user