зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1399076 - Error when weakref of web element is destroyed. r=automatedtester
Take into account that a weak referenced element might have been destroyed in the element staleness check. An error is thrown when the reference object has been destroyed when getting a weakrefs' pointer. We catch this, but element.isStale does not take into account that the el argument in this case can be null, or in this revision of the patch, undefined. MozReview-Commit-ID: 7sr4YGhAotS --HG-- extra : rebase_source : 995eeef4ec1b19bf100cb95c4dd343e947b1cf52
This commit is contained in:
Родитель
d4bfc7402c
Коммит
b803b6e1dc
|
@ -160,27 +160,30 @@ element.Store = class {
|
|||
* Element associated with reference.
|
||||
*
|
||||
* @throws {NoSuchElementError}
|
||||
* If the provided reference is unknown.
|
||||
* If the web element reference <var>uuid</var> has not been
|
||||
* seen before.
|
||||
* @throws {StaleElementReferenceError}
|
||||
* If element has gone stale, indicating it is no longer attached to
|
||||
* the DOM provided in the container.
|
||||
* If the element has gone stale, indicating it is no longer
|
||||
* attached to the DOM, or its node document is no longer the
|
||||
* active document.
|
||||
*/
|
||||
get(uuid) {
|
||||
let el = this.els[uuid];
|
||||
if (!el) {
|
||||
throw new NoSuchElementError("Element reference not seen before: " + uuid);
|
||||
if (!this.has(uuid)) {
|
||||
throw new NoSuchElementError(
|
||||
"Web element reference not seen before: " + uuid);
|
||||
}
|
||||
|
||||
let el;
|
||||
let ref = this.els[uuid];
|
||||
try {
|
||||
el = el.get();
|
||||
el = ref.get();
|
||||
} catch (e) {
|
||||
el = null;
|
||||
delete this.els[uuid];
|
||||
}
|
||||
|
||||
if (element.isStale(el)) {
|
||||
throw new StaleElementReferenceError(
|
||||
pprint`The element reference of ${el} stale; ` +
|
||||
pprint`The element reference of ${el || uuid} stale; ` +
|
||||
"either the element is no longer attached to the DOM " +
|
||||
"or the document has been refreshed");
|
||||
}
|
||||
|
@ -633,12 +636,16 @@ element.generateUUID = function() {
|
|||
* True if <var>el</var> is stale, false otherwise.
|
||||
*/
|
||||
element.isStale = function(el) {
|
||||
if (!el) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let doc = el.ownerDocument;
|
||||
let win = doc.defaultView;
|
||||
|
||||
if (!win || el.ownerDocument !== win.document) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !el.isConnected;
|
||||
};
|
||||
|
||||
|
|
|
@ -275,12 +275,12 @@ class TestScreenCaptureChrome(WindowManagerMixin, ScreenCaptureTestCase):
|
|||
self.marionette.navigate(box)
|
||||
content_element = self.marionette.find_element(By.ID, "green")
|
||||
|
||||
self.assertRaisesRegexp(NoSuchElementException, "Element reference not seen before",
|
||||
self.assertRaisesRegexp(NoSuchElementException, "Web element reference not seen before",
|
||||
self.marionette.screenshot, highlights=[content_element])
|
||||
|
||||
chrome_document_element = self.document_element
|
||||
with self.marionette.using_context('content'):
|
||||
self.assertRaisesRegexp(NoSuchElementException, "Element reference not seen before",
|
||||
self.assertRaisesRegexp(NoSuchElementException, "Web element reference not seen before",
|
||||
self.marionette.screenshot,
|
||||
highlights=[chrome_document_element])
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче