mirror of
https://github.com/servo/servo.git
synced 2025-09-10 06:58:21 +01:00
webdriver: Improve parsing of Frame and Window (#39012)
In #38745, we changed the id of Frame and Window as the result of `ToString` trait. This PR - adapts the parsing of frame/window accordingly. - for frame, return the [WindowProxy](https://developer.mozilla.org/en-US/docs/Web/API/WindowProxy) object of the iframe as it's supposed to do. Testing: `execute_{async_}script/arguments.py` --------- Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
parent
00c1f79a1d
commit
8305064522
4 changed files with 15 additions and 22 deletions
|
@ -1468,13 +1468,21 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
||||||
find_node_by_unique_id_in_document(&self.Document(), id.into()).and_then(Root::downcast)
|
find_node_by_unique_id_in_document(&self.Document(), id.into()).and_then(Root::downcast)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn WebdriverFrame(&self, id: DOMString) -> Option<DomRoot<Element>> {
|
fn WebdriverFrame(&self, browsing_context_id: DOMString) -> Option<DomRoot<WindowProxy>> {
|
||||||
find_node_by_unique_id_in_document(&self.Document(), id.into())
|
self.Document()
|
||||||
.and_then(Root::downcast::<HTMLIFrameElement>)
|
.iframes()
|
||||||
.map(Root::upcast::<Element>)
|
.iter()
|
||||||
|
.find(|iframe| {
|
||||||
|
iframe
|
||||||
|
.browsing_context_id()
|
||||||
|
.as_ref()
|
||||||
|
.map(BrowsingContextId::to_string) ==
|
||||||
|
Some(browsing_context_id.to_string())
|
||||||
|
})
|
||||||
|
.and_then(|iframe| iframe.GetContentWindow())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn WebdriverWindow(&self, id: DOMString) -> Option<DomRoot<WindowProxy>> {
|
fn WebdriverWindow(&self, webview_id: DOMString) -> Option<DomRoot<WindowProxy>> {
|
||||||
let window_proxy = self.window_proxy.get()?;
|
let window_proxy = self.window_proxy.get()?;
|
||||||
|
|
||||||
// Window must be top level browsing context.
|
// Window must be top level browsing context.
|
||||||
|
@ -1482,10 +1490,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipeline_id = window_proxy.currently_active()?;
|
if self.webview_id().to_string() == webview_id.str() {
|
||||||
let document = ScriptThread::find_document(pipeline_id)?;
|
|
||||||
|
|
||||||
if document.upcast::<Node>().unique_id(pipeline_id) == id.str() {
|
|
||||||
Some(DomRoot::from_ref(&window_proxy))
|
Some(DomRoot::from_ref(&window_proxy))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -151,7 +151,7 @@ partial interface Window {
|
||||||
undefined webdriverException(optional any result);
|
undefined webdriverException(optional any result);
|
||||||
undefined webdriverTimeout();
|
undefined webdriverTimeout();
|
||||||
Element? webdriverElement(DOMString id);
|
Element? webdriverElement(DOMString id);
|
||||||
Element? webdriverFrame(DOMString id);
|
WindowProxy? webdriverFrame(DOMString id);
|
||||||
WindowProxy? webdriverWindow(DOMString id);
|
WindowProxy? webdriverWindow(DOMString id);
|
||||||
ShadowRoot? webdriverShadowRoot(DOMString id);
|
ShadowRoot? webdriverShadowRoot(DOMString id);
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,9 +31,3 @@
|
||||||
|
|
||||||
[test_no_such_window_for_window_with_invalid_value]
|
[test_no_such_window_for_window_with_invalid_value]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[test_element_reference[frame\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_element_reference[window\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -31,9 +31,3 @@
|
||||||
|
|
||||||
[test_no_such_window_for_window_with_invalid_value]
|
[test_no_such_window_for_window_with_invalid_value]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[test_element_reference[frame\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test_element_reference[window\]]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue