diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 27ee62a7552..73a1502666a 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1468,13 +1468,21 @@ impl WindowMethods for Window { find_node_by_unique_id_in_document(&self.Document(), id.into()).and_then(Root::downcast) } - fn WebdriverFrame(&self, id: DOMString) -> Option> { - find_node_by_unique_id_in_document(&self.Document(), id.into()) - .and_then(Root::downcast::) - .map(Root::upcast::) + fn WebdriverFrame(&self, browsing_context_id: DOMString) -> Option> { + self.Document() + .iframes() + .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> { + fn WebdriverWindow(&self, webview_id: DOMString) -> Option> { let window_proxy = self.window_proxy.get()?; // Window must be top level browsing context. @@ -1482,10 +1490,7 @@ impl WindowMethods for Window { return None; } - let pipeline_id = window_proxy.currently_active()?; - let document = ScriptThread::find_document(pipeline_id)?; - - if document.upcast::().unique_id(pipeline_id) == id.str() { + if self.webview_id().to_string() == webview_id.str() { Some(DomRoot::from_ref(&window_proxy)) } else { None diff --git a/components/script_bindings/webidls/Window.webidl b/components/script_bindings/webidls/Window.webidl index ec95eadfab5..f62842a22b6 100644 --- a/components/script_bindings/webidls/Window.webidl +++ b/components/script_bindings/webidls/Window.webidl @@ -151,7 +151,7 @@ partial interface Window { undefined webdriverException(optional any result); undefined webdriverTimeout(); Element? webdriverElement(DOMString id); - Element? webdriverFrame(DOMString id); + WindowProxy? webdriverFrame(DOMString id); WindowProxy? webdriverWindow(DOMString id); ShadowRoot? webdriverShadowRoot(DOMString id); }; diff --git a/tests/wpt/meta/webdriver/tests/classic/execute_async_script/arguments.py.ini b/tests/wpt/meta/webdriver/tests/classic/execute_async_script/arguments.py.ini index 5f1d34e6018..57516fe7f2a 100644 --- a/tests/wpt/meta/webdriver/tests/classic/execute_async_script/arguments.py.ini +++ b/tests/wpt/meta/webdriver/tests/classic/execute_async_script/arguments.py.ini @@ -31,9 +31,3 @@ [test_no_such_window_for_window_with_invalid_value] expected: FAIL - - [test_element_reference[frame\]] - expected: FAIL - - [test_element_reference[window\]] - expected: FAIL diff --git a/tests/wpt/meta/webdriver/tests/classic/execute_script/arguments.py.ini b/tests/wpt/meta/webdriver/tests/classic/execute_script/arguments.py.ini index 5f1d34e6018..57516fe7f2a 100644 --- a/tests/wpt/meta/webdriver/tests/classic/execute_script/arguments.py.ini +++ b/tests/wpt/meta/webdriver/tests/classic/execute_script/arguments.py.ini @@ -31,9 +31,3 @@ [test_no_such_window_for_window_with_invalid_value] expected: FAIL - - [test_element_reference[frame\]] - expected: FAIL - - [test_element_reference[window\]] - expected: FAIL