mirror of
https://github.com/servo/servo.git
synced 2025-07-22 06:43:40 +01:00
Improve some webdriver conformance tests results (#36673)
These changes allow test_dom_token_list from /execute_script/collections.py to pass, and various tests in /execute_script/arguments.py to expose new failures. Testing: Not run in CI yet, but verified results from tests/wpt/tests/webdriver/tests/classic/{execute_script,execute_async_script} locally. Fixes: #35738 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
a18c6e2c78
commit
f47e69c112
28 changed files with 128 additions and 165 deletions
|
@ -65,6 +65,7 @@ use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
|||
use script_bindings::codegen::GenericBindings::NavigatorBinding::NavigatorMethods;
|
||||
use script_bindings::codegen::GenericBindings::PerformanceBinding::PerformanceMethods;
|
||||
use script_bindings::interfaces::WindowHelpers;
|
||||
use script_bindings::root::Root;
|
||||
use script_layout_interface::{
|
||||
FragmentType, Layout, PendingImageState, QueryMsg, Reflow, ReflowGoal, ReflowRequest,
|
||||
TrustedNodeAddress, combine_id_with_fragment_type,
|
||||
|
@ -146,6 +147,7 @@ use crate::dom::performance::Performance;
|
|||
use crate::dom::promise::Promise;
|
||||
use crate::dom::screen::Screen;
|
||||
use crate::dom::selection::Selection;
|
||||
use crate::dom::shadowroot::ShadowRoot;
|
||||
use crate::dom::storage::Storage;
|
||||
#[cfg(feature = "bluetooth")]
|
||||
use crate::dom::testrunner::TestRunner;
|
||||
|
@ -165,7 +167,7 @@ use crate::script_runtime::{CanGc, JSContext, Runtime};
|
|||
use crate::script_thread::ScriptThread;
|
||||
use crate::timers::{IsInterval, TimerCallback};
|
||||
use crate::unminify::unminified_path;
|
||||
use crate::webdriver_handlers::jsval_to_webdriver;
|
||||
use crate::webdriver_handlers::{find_node_by_unique_id_in_document, jsval_to_webdriver};
|
||||
use crate::{fetch, window_named_properties};
|
||||
|
||||
/// A callback to call when a response comes back from the `ImageCache`.
|
||||
|
@ -1394,6 +1396,30 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
}
|
||||
}
|
||||
|
||||
fn WebdriverElement(&self, id: DOMString) -> Option<DomRoot<Element>> {
|
||||
find_node_by_unique_id_in_document(&self.Document(), id.into())
|
||||
.ok()
|
||||
.and_then(Root::downcast)
|
||||
}
|
||||
|
||||
fn WebdriverFrame(&self, id: DOMString) -> Option<DomRoot<Element>> {
|
||||
find_node_by_unique_id_in_document(&self.Document(), id.into())
|
||||
.ok()
|
||||
.and_then(Root::downcast::<HTMLIFrameElement>)
|
||||
.map(Root::upcast::<Element>)
|
||||
}
|
||||
|
||||
fn WebdriverWindow(&self, _id: DOMString) -> Option<DomRoot<Window>> {
|
||||
warn!("Window references are not supported in webdriver yet");
|
||||
None
|
||||
}
|
||||
|
||||
fn WebdriverShadowRoot(&self, id: DOMString) -> Option<DomRoot<ShadowRoot>> {
|
||||
find_node_by_unique_id_in_document(&self.Document(), id.into())
|
||||
.ok()
|
||||
.and_then(Root::downcast)
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle
|
||||
fn GetComputedStyle(
|
||||
&self,
|
||||
|
|
|
@ -53,6 +53,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::reflector::{DomGlobal, DomObject};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
|
@ -77,12 +78,27 @@ fn find_node_by_unique_id(
|
|||
pipeline: PipelineId,
|
||||
node_id: String,
|
||||
) -> Result<DomRoot<Node>, ErrorStatus> {
|
||||
match documents.find_document(pipeline).and_then(|document| {
|
||||
document
|
||||
.upcast::<Node>()
|
||||
.traverse_preorder(ShadowIncluding::Yes)
|
||||
.find(|node| node.unique_id() == node_id)
|
||||
}) {
|
||||
match documents.find_document(pipeline) {
|
||||
Some(doc) => find_node_by_unique_id_in_document(&doc, node_id),
|
||||
None => {
|
||||
if ScriptThread::has_node_id(&node_id) {
|
||||
Err(ErrorStatus::StaleElementReference)
|
||||
} else {
|
||||
Err(ErrorStatus::NoSuchElement)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn find_node_by_unique_id_in_document(
|
||||
document: &Document,
|
||||
node_id: String,
|
||||
) -> Result<DomRoot<Node>, ErrorStatus> {
|
||||
match document
|
||||
.upcast::<Node>()
|
||||
.traverse_preorder(ShadowIncluding::Yes)
|
||||
.find(|node| node.unique_id() == node_id)
|
||||
{
|
||||
Some(node) => Ok(node),
|
||||
None => {
|
||||
if ScriptThread::has_node_id(&node_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue