mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
servoshell: Do not focus and raise new auxiliary WebDriver-created WebView
s (#37284)
For Desktop port of `request_open_auxiliary_webview`, stay on the original WebView if the request originates WebDriver. This is to make sure `webdriver_server::handle_new_window` does not focus the new window, according to spec. Seec7eba2dbba/tests/wpt/tests/webdriver/tests/classic/new_window/new_window.py (L31-L37)
**To clarify**: this won't change the behaviour when user interacts, but only affects WebDriver [New Window](https://w3c.github.io/webdriver/#new-window). Testing: `./mach test-wpt -r --log-raw "D:/servo log/all.txt" ./tests/wpt/tests/webdriver/tests/classic --product servodriver` based on96b0973037
--------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
parent
0fa3de3937
commit
a3c792e5aa
27 changed files with 76 additions and 158 deletions
|
@ -466,26 +466,40 @@ impl WindowProxy {
|
|||
features: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<Option<DomRoot<WindowProxy>>> {
|
||||
// Step 4.
|
||||
// Step 5. If target is the empty string, then set target to "_blank".
|
||||
let non_empty_target = match target.as_ref() {
|
||||
"" => DOMString::from("_blank"),
|
||||
_ => target,
|
||||
};
|
||||
// Step 5
|
||||
// Step 6. Let tokenizedFeatures be the result of tokenizing features.
|
||||
let tokenized_features = tokenize_open_features(features);
|
||||
// Step 7-9
|
||||
// Step 7 - 8.
|
||||
// If tokenizedFeatures["noreferrer"] exists, then set noreferrer to
|
||||
// the result of parsing tokenizedFeatures["noreferrer"] as a boolean feature.
|
||||
let noreferrer = parse_open_feature_boolean(&tokenized_features, "noreferrer");
|
||||
|
||||
// Step 9. Let noopener be the result of getting noopener for window
|
||||
// open with sourceDocument, tokenizedFeatures, and urlRecord.
|
||||
let noopener = if noreferrer {
|
||||
true
|
||||
} else {
|
||||
parse_open_feature_boolean(&tokenized_features, "noopener")
|
||||
};
|
||||
// Step 10, 11
|
||||
// (TODO) Step 10. Remove tokenizedFeatures["noopener"] and tokenizedFeatures["noreferrer"].
|
||||
|
||||
// (TODO) Step 11. Let referrerPolicy be the empty string.
|
||||
// (TODO) Step 12. If noreferrer is true, then set referrerPolicy to "no-referrer".
|
||||
|
||||
// Step 13 - 14
|
||||
// Let targetNavigable and windowType be the result of applying the rules for
|
||||
// choosing a navigable given target, sourceDocument's node navigable, and noopener.
|
||||
// If targetNavigable is null, then return null.
|
||||
let (chosen, new) = match self.choose_browsing_context(non_empty_target, noopener) {
|
||||
(Some(chosen), new) => (chosen, new),
|
||||
(None, _) => return Ok(None),
|
||||
};
|
||||
// TODO Step 12, set up browsing context features.
|
||||
// TODO Step 15.2, Set up browsing context features for targetNavigable's
|
||||
// active browsing context given tokenizedFeatures.
|
||||
let target_document = match chosen.document() {
|
||||
Some(target_document) => target_document,
|
||||
None => return Ok(None),
|
||||
|
@ -496,7 +510,7 @@ impl WindowProxy {
|
|||
false
|
||||
};
|
||||
let target_window = target_document.window();
|
||||
// Step 13, and 14.4, will have happened elsewhere,
|
||||
// Step 15.3 and 15.4 will have happened elsewhere,
|
||||
// since we've created a new browsing context and loaded it with about:blank.
|
||||
if !url.is_empty() {
|
||||
let existing_document = self
|
||||
|
@ -504,18 +518,18 @@ impl WindowProxy {
|
|||
.get()
|
||||
.and_then(ScriptThread::find_document)
|
||||
.unwrap();
|
||||
// Step 14.1
|
||||
let url = match existing_document.url().join(&url) {
|
||||
Ok(url) => url,
|
||||
Err(_) => return Err(Error::Syntax),
|
||||
};
|
||||
// Step 14.3
|
||||
let referrer = if noreferrer {
|
||||
Referrer::NoReferrer
|
||||
} else {
|
||||
target_window.as_global_scope().get_referrer()
|
||||
};
|
||||
// Step 14.5
|
||||
// Step 15.5 Otherwise, navigate targetNavigable to urlRecord using sourceDocument,
|
||||
// with referrerPolicy set to referrerPolicy and exceptionsEnabled set to true.
|
||||
// FIXME: referrerPolicy may not be used properly here. exceptionsEnabled not used.
|
||||
let referrer_policy = target_document.get_referrer_policy();
|
||||
let pipeline_id = target_window.pipeline_id();
|
||||
let secure = target_window.as_global_scope().is_secure_context();
|
||||
|
@ -534,14 +548,13 @@ impl WindowProxy {
|
|||
} else {
|
||||
NavigationHistoryBehavior::Push
|
||||
};
|
||||
|
||||
target_window.load_url(history_handling, false, load_data, can_gc);
|
||||
}
|
||||
// Step 17 (Dis-owning has been done in create_auxiliary_browsing_context).
|
||||
if noopener {
|
||||
// Step 15 (Dis-owning has been done in create_auxiliary_browsing_context).
|
||||
return Ok(None);
|
||||
}
|
||||
// Step 17.
|
||||
// Step 18
|
||||
Ok(target_document.browsing_context())
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,8 @@ fn find_node_by_unique_id(
|
|||
match documents.find_document(pipeline) {
|
||||
Some(doc) => find_node_by_unique_id_in_document(&doc, node_id),
|
||||
None => {
|
||||
// FIXME: This is unreacheable!! Because we already early return in Constellation
|
||||
// To be Fixed soon
|
||||
if ScriptThread::has_node_id(pipeline, &node_id) {
|
||||
Err(ErrorStatus::StaleElementReference)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue