Just the code, no metadata for now

This commit is contained in:
Patrick Shaughnessy 2020-01-01 18:11:46 -05:00
parent 45cc558297
commit 3bd30afcf3
2 changed files with 25 additions and 21 deletions

View file

@ -370,6 +370,8 @@ pub struct Document {
page_showing: Cell<bool>, page_showing: Cell<bool>,
/// Whether the document is salvageable. /// Whether the document is salvageable.
salvageable: Cell<bool>, salvageable: Cell<bool>,
/// Whether the document was aborted with an active parser
active_parser_was_aborted: Cell<bool>,
/// Whether the unload event has already been fired. /// Whether the unload event has already been fired.
fired_unload: Cell<bool>, fired_unload: Cell<bool>,
/// List of responsive images /// List of responsive images
@ -2264,6 +2266,7 @@ impl Document {
// Step 3. // Step 3.
if let Some(parser) = self.get_current_parser() { if let Some(parser) = self.get_current_parser() {
self.active_parser_was_aborted.set(true);
parser.abort(); parser.abort();
self.salvageable.set(false); self.salvageable.set(false);
} }
@ -2812,6 +2815,7 @@ impl Document {
throw_on_dynamic_markup_insertion_counter: Cell::new(0), throw_on_dynamic_markup_insertion_counter: Cell::new(0),
page_showing: Cell::new(false), page_showing: Cell::new(false),
salvageable: Cell::new(true), salvageable: Cell::new(true),
active_parser_was_aborted: Cell::new(false),
fired_unload: Cell::new(false), fired_unload: Cell::new(false),
responsive_images: Default::default(), responsive_images: Default::default(),
redirect_count: Cell::new(0), redirect_count: Cell::new(0),
@ -4458,18 +4462,25 @@ impl DocumentMethods for Document {
return Ok(DomRoot::from_ref(self)); return Ok(DomRoot::from_ref(self));
} }
// Step 7
if self.active_parser_was_aborted.get() {
return Ok(DomRoot::from_ref(self));
}
// TODO: prompt to unload. // TODO: prompt to unload.
// TODO: set unload_event_start and unload_event_end // TODO: set unload_event_start and unload_event_end
window_from_node(self).set_navigation_start(); window_from_node(self).set_navigation_start();
// Step 7 // Step 8
// TODO: https://github.com/servo/servo/issues/21937 // TODO: https://github.com/servo/servo/issues/21937
if self.has_browsing_context() { if self.has_browsing_context() {
// spec says "stop document loading",
// which is a process that does more than just abort
self.abort(); self.abort();
} }
// Step 8 // Step 9
for node in self for node in self
.upcast::<Node>() .upcast::<Node>()
.traverse_preorder(ShadowIncluding::Yes) .traverse_preorder(ShadowIncluding::Yes)
@ -4477,16 +4488,16 @@ impl DocumentMethods for Document {
node.upcast::<EventTarget>().remove_all_listeners(); node.upcast::<EventTarget>().remove_all_listeners();
} }
// Step 9 // Step 10
if self.window.Document() == DomRoot::from_ref(self) { if self.window.Document() == DomRoot::from_ref(self) {
self.window.upcast::<EventTarget>().remove_all_listeners(); self.window.upcast::<EventTarget>().remove_all_listeners();
} }
// Step 10 // Step 11
// TODO: https://github.com/servo/servo/issues/21936 // TODO: https://github.com/servo/servo/issues/21936
Node::replace_all(None, self.upcast::<Node>()); Node::replace_all(None, self.upcast::<Node>());
// Step 11 // Step 12
if self.is_fully_active() { if self.is_fully_active() {
let mut new_url = entry_responsible_document.url(); let mut new_url = entry_responsible_document.url();
if entry_responsible_document != DomRoot::from_ref(self) { if entry_responsible_document != DomRoot::from_ref(self) {
@ -4496,13 +4507,13 @@ impl DocumentMethods for Document {
self.set_url(new_url); self.set_url(new_url);
} }
// Step 12 // Step 13
// TODO: https://github.com/servo/servo/issues/21938 // TODO: https://github.com/servo/servo/issues/21938
// Step 13 // Step 14
self.set_quirks_mode(QuirksMode::NoQuirks); self.set_quirks_mode(QuirksMode::NoQuirks);
// Step 14 // Step 15
let resource_threads = self let resource_threads = self
.window .window
.upcast::<GlobalScope>() .upcast::<GlobalScope>()
@ -4512,13 +4523,13 @@ impl DocumentMethods for Document {
DocumentLoader::new_with_threads(resource_threads, Some(self.url())); DocumentLoader::new_with_threads(resource_threads, Some(self.url()));
ServoParser::parse_html_script_input(self, self.url()); ServoParser::parse_html_script_input(self, self.url());
// Step 15 // Step 16
self.ready_state.set(DocumentReadyState::Loading); self.ready_state.set(DocumentReadyState::Loading);
// Step 16
// Handled when creating the parser in step 14
// Step 17 // Step 17
// Handled when creating the parser in step 15
// Step 18
Ok(DomRoot::from_ref(self)) Ok(DomRoot::from_ref(self))
} }
@ -4550,8 +4561,8 @@ impl DocumentMethods for Document {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
if !self.is_active() { // Step 3 - what specifies the is_active() part here?
// Step 3. if !self.is_active() || self.active_parser_was_aborted.get() {
return Ok(()); return Ok(());
} }

View file

@ -1,7 +0,0 @@
[aborted-parser.window.html]
[document.open() after parser is aborted]
expected: FAIL
[async document.open() after parser is aborted]
expected: FAIL