mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Don't run scripts in documents that don't have a browsing context (#35871)
* Don't run scripts in document that don't have a browsing context For confirmation that this is correct, refer to the note under Step 3 of https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
1200617683
commit
ccd4b113a8
4 changed files with 8 additions and 3 deletions
|
@ -267,6 +267,7 @@ impl Tokenizer {
|
||||||
// Create new thread for HtmlTokenizer. This is where parser actions
|
// Create new thread for HtmlTokenizer. This is where parser actions
|
||||||
// will be generated from the input provided. These parser actions are then passed
|
// will be generated from the input provided. These parser actions are then passed
|
||||||
// onto the main thread to be executed.
|
// onto the main thread to be executed.
|
||||||
|
let scripting_enabled = document.has_browsing_context();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name(format!("Parse:{}", tokenizer.url.debug_compact()))
|
.name(format!("Parse:{}", tokenizer.url.debug_compact()))
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
@ -277,6 +278,7 @@ impl Tokenizer {
|
||||||
form_parse_node,
|
form_parse_node,
|
||||||
to_tokenizer_sender,
|
to_tokenizer_sender,
|
||||||
html_tokenizer_receiver,
|
html_tokenizer_receiver,
|
||||||
|
scripting_enabled,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.expect("HTML Parser thread spawning failed");
|
.expect("HTML Parser thread spawning failed");
|
||||||
|
@ -573,9 +575,11 @@ fn run(
|
||||||
form_parse_node: Option<ParseNode>,
|
form_parse_node: Option<ParseNode>,
|
||||||
sender: Sender<ToTokenizerMsg>,
|
sender: Sender<ToTokenizerMsg>,
|
||||||
receiver: Receiver<ToHtmlTokenizerMsg>,
|
receiver: Receiver<ToHtmlTokenizerMsg>,
|
||||||
|
scripting_enabled: bool,
|
||||||
) {
|
) {
|
||||||
let options = TreeBuilderOpts {
|
let options = TreeBuilderOpts {
|
||||||
ignore_missing_rules: true,
|
ignore_missing_rules: true,
|
||||||
|
scripting_enabled,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ impl Tokenizer {
|
||||||
|
|
||||||
let options = TreeBuilderOpts {
|
let options = TreeBuilderOpts {
|
||||||
ignore_missing_rules: true,
|
ignore_missing_rules: true,
|
||||||
|
scripting_enabled: document.has_browsing_context(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[DOMParser-parseFromString-html.html]
|
|
||||||
[must be parsed with scripting disabled, so noscript works]
|
|
||||||
expected: FAIL
|
|
3
tests/wpt/meta/html/syntax/parsing-html-fragments/tokenizer-modes-001.html.ini
vendored
Normal file
3
tests/wpt/meta/html/syntax/parsing-html-fragments/tokenizer-modes-001.html.ini
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[tokenizer-modes-001.html]
|
||||||
|
[</noscript> should not break out of noscript.]
|
||||||
|
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue