Serenity Operating System
at master 574 lines 27 kB view raw
1/* 2 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2022, networkException <networkexception@serenityos.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#include <AK/Debug.h> 9#include <AK/StringBuilder.h> 10#include <LibTextCodec/Decoder.h> 11#include <LibWeb/Bindings/Intrinsics.h> 12#include <LibWeb/DOM/Document.h> 13#include <LibWeb/DOM/Event.h> 14#include <LibWeb/DOM/ShadowRoot.h> 15#include <LibWeb/DOM/Text.h> 16#include <LibWeb/HTML/EventNames.h> 17#include <LibWeb/HTML/HTMLScriptElement.h> 18#include <LibWeb/HTML/Scripting/ClassicScript.h> 19#include <LibWeb/HTML/Scripting/Fetching.h> 20#include <LibWeb/Infra/CharacterTypes.h> 21#include <LibWeb/Infra/Strings.h> 22#include <LibWeb/Loader/ResourceLoader.h> 23#include <LibWeb/MimeSniff/MimeType.h> 24 25namespace Web::HTML { 26 27HTMLScriptElement::HTMLScriptElement(DOM::Document& document, DOM::QualifiedName qualified_name) 28 : HTMLElement(document, move(qualified_name)) 29{ 30} 31 32HTMLScriptElement::~HTMLScriptElement() = default; 33 34JS::ThrowCompletionOr<void> HTMLScriptElement::initialize(JS::Realm& realm) 35{ 36 MUST_OR_THROW_OOM(Base::initialize(realm)); 37 set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLScriptElementPrototype>(realm, "HTMLScriptElement")); 38 39 return {}; 40} 41 42void HTMLScriptElement::visit_edges(Cell::Visitor& visitor) 43{ 44 Base::visit_edges(visitor); 45 if (auto* script = m_result.get_pointer<JS::NonnullGCPtr<Script>>()) 46 visitor.visit(script->ptr()); 47 visitor.visit(m_parser_document.ptr()); 48 visitor.visit(m_preparation_time_document.ptr()); 49} 50 51void HTMLScriptElement::begin_delaying_document_load_event(DOM::Document& document) 52{ 53 // https://html.spec.whatwg.org/multipage/scripting.html#concept-script-script 54 // The user agent must delay the load event of the element's node document until the script is ready. 55 m_document_load_event_delayer.emplace(document); 56} 57 58// https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block 59void HTMLScriptElement::execute_script() 60{ 61 // 1. Let document be el's node document. 62 JS::NonnullGCPtr<DOM::Document> document = this->document(); 63 64 // 2. If el's preparation-time document is not equal to document, then return. 65 if (m_preparation_time_document.ptr() != document.ptr()) { 66 dbgln("HTMLScriptElement: Refusing to run script because the preparation time document is not the same as the node document."); 67 return; 68 } 69 70 // FIXME: 3. Unblock rendering on el. 71 72 // 3. If el's result is null, then fire an event named error at el, and return. 73 if (m_result.has<ResultState::Null>()) { 74 dbgln("HTMLScriptElement: Refusing to run script because the element's result is null."); 75 dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); 76 return; 77 } 78 79 // 5. If el's from an external file is true, or el's type is "module", then increment document's ignore-destructive-writes counter. 80 bool incremented_destructive_writes_counter = false; 81 if (m_from_an_external_file || m_script_type == ScriptType::Module) { 82 document->increment_ignore_destructive_writes_counter(); 83 incremented_destructive_writes_counter = true; 84 } 85 86 // 5. Switch on el's type: 87 // -> "classic" 88 if (m_script_type == ScriptType::Classic) { 89 // 1. Let oldCurrentScript be the value to which document's currentScript object was most recently set. 90 auto old_current_script = document->current_script(); 91 // 2. If el's root is not a shadow root, then set document's currentScript attribute to el. Otherwise, set it to null. 92 if (!is<DOM::ShadowRoot>(root())) 93 document->set_current_script({}, this); 94 else 95 document->set_current_script({}, nullptr); 96 97 if (m_from_an_external_file) 98 dbgln_if(HTML_SCRIPT_DEBUG, "HTMLScriptElement: Running script {}", attribute(HTML::AttributeNames::src)); 99 else 100 dbgln_if(HTML_SCRIPT_DEBUG, "HTMLScriptElement: Running inline script"); 101 102 // 3. Run the classic script given by el's result. 103 (void)verify_cast<ClassicScript>(*m_result.get<JS::NonnullGCPtr<Script>>()).run(); 104 105 // 4. Set document's currentScript attribute to oldCurrentScript. 106 document->set_current_script({}, old_current_script); 107 } 108 // -> "module" 109 else if (m_script_type == ScriptType::Module) { 110 // 1. Assert: document's currentScript attribute is null. 111 VERIFY(document->current_script() == nullptr); 112 113 // 2. Run the module script given by el's result. 114 (void)verify_cast<JavaScriptModuleScript>(*m_result.get<JS::NonnullGCPtr<Script>>()).run(); 115 } else if (m_script_type == ScriptType::ImportMap) { 116 // FIXME: 1. Register an import map given el's relevant global object and el's result. 117 dbgln("FIXME: HTMLScriptElement import map support"); 118 } 119 120 // 7. Decrement the ignore-destructive-writes counter of document, if it was incremented in the earlier step. 121 if (incremented_destructive_writes_counter) 122 document->decrement_ignore_destructive_writes_counter(); 123 124 // 8. If el's from an external file is true, then fire an event named load at el. 125 if (m_from_an_external_file) 126 dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); 127} 128 129// https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script 130void HTMLScriptElement::prepare_script() 131{ 132 // 1. If el's already started is true, then return. 133 if (m_already_started) { 134 dbgln("HTMLScriptElement: Refusing to run script because it has already started."); 135 return; 136 } 137 138 // 2. Let parser document be el's parser document. 139 JS::GCPtr<DOM::Document> parser_document = m_parser_document; 140 141 // 3. Set el's parser document to null. 142 m_parser_document = nullptr; 143 144 // 4. If parser document is non-null and el does not have an async attribute, then set el's force async to true. 145 if (parser_document && !has_attribute(HTML::AttributeNames::async)) { 146 m_force_async = true; 147 } 148 149 // 5. Let source text be el's child text content. 150 auto source_text = child_text_content(); 151 152 // 6. If el has no src attribute, and source text is the empty string, then return. 153 if (!has_attribute(HTML::AttributeNames::src) && source_text.is_empty()) { 154 return; 155 } 156 157 // 7. If el is not connected, then return. 158 if (!is_connected()) { 159 dbgln("HTMLScriptElement: Refusing to run script because the element is not connected."); 160 return; 161 } 162 163 // 8. If any of the following are true: 164 // - el has a type attribute whose value is the empty string; 165 // - el has no type attribute but it has a language attribute and that attribute's value is the empty string; or 166 // - el has neither a type attribute nor a language attribute 167 DeprecatedString script_block_type; 168 bool has_type_attribute = has_attribute(HTML::AttributeNames::type); 169 bool has_language_attribute = has_attribute(HTML::AttributeNames::language); 170 if ((has_type_attribute && attribute(HTML::AttributeNames::type).is_empty()) 171 || (!has_type_attribute && has_language_attribute && attribute(HTML::AttributeNames::language).is_empty()) 172 || (!has_type_attribute && !has_language_attribute)) { 173 // then let the script block's type string for this script element be "text/javascript". 174 script_block_type = "text/javascript"; 175 } 176 // Otherwise, if el has a type attribute, 177 else if (has_type_attribute) { 178 // then let the script block's type string be the value of that attribute with leading and trailing ASCII whitespace stripped. 179 script_block_type = attribute(HTML::AttributeNames::type).trim(Infra::ASCII_WHITESPACE); 180 } 181 // Otherwise, el has a non-empty language attribute; 182 else if (!attribute(HTML::AttributeNames::language).is_empty()) { 183 // let the script block's type string be the concatenation of "text/" and the value of el's language attribute. 184 script_block_type = DeprecatedString::formatted("text/{}", attribute(HTML::AttributeNames::language)); 185 } 186 187 // 9. If the script block's type string is a JavaScript MIME type essence match, 188 if (MimeSniff::is_javascript_mime_type_essence_match(script_block_type.trim(Infra::ASCII_WHITESPACE))) { 189 // then set el's type to "classic". 190 m_script_type = ScriptType::Classic; 191 } 192 // 10. Otherwise, if the script block's type string is an ASCII case-insensitive match for the string "module", 193 else if (Infra::is_ascii_case_insensitive_match(script_block_type, "module"sv)) { 194 // then set el's type to "module". 195 m_script_type = ScriptType::Module; 196 } 197 // 11. Otherwise, if the script block's type string is an ASCII case-insensitive match for the string "importmap", 198 else if (Infra::is_ascii_case_insensitive_match(script_block_type, "importmap"sv)) { 199 // then set el's type to "importmap". 200 m_script_type = ScriptType::ImportMap; 201 } 202 // 12. Otherwise, return. (No script is executed, and el's type is left as null.) 203 else { 204 VERIFY(m_script_type == ScriptType::Null); 205 dbgln("HTMLScriptElement: Refusing to run script because the type '{}' is not recognized.", script_block_type); 206 return; 207 } 208 209 // 13. If parser document is non-null, then set el's parser document back to parser document and set el's force async to false. 210 if (parser_document) { 211 m_parser_document = parser_document; 212 m_force_async = false; 213 } 214 215 // 14. Set el's already started to true. 216 m_already_started = true; 217 218 // 15. Set el's preparation-time document to its node document. 219 m_preparation_time_document = &document(); 220 221 // 16. If parser document is non-null, and parser document is not equal to el's preparation-time document, then return. 222 if (parser_document != nullptr && parser_document != m_preparation_time_document) { 223 dbgln("HTMLScriptElement: Refusing to run script because the parser document is not the same as the preparation time document."); 224 return; 225 } 226 227 // 17. If scripting is disabled for el, then return. 228 if (is_scripting_disabled()) { 229 dbgln("HTMLScriptElement: Refusing to run script because scripting is disabled."); 230 return; 231 } 232 233 // 18. If el has a nomodule content attribute and its type is "classic", then return. 234 if (m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::nomodule)) { 235 dbgln("HTMLScriptElement: Refusing to run classic script because it has the nomodule attribute."); 236 return; 237 } 238 239 // FIXME: 19. If el does not have a src content attribute, and the Should element's inline behavior be blocked by Content Security Policy? 240 // algorithm returns "Blocked" when given el, "script", and source text, then return. [CSP] 241 242 // 20. If el has an event attribute and a for attribute, and el's type is "classic", then: 243 if (m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::event) && has_attribute(HTML::AttributeNames::for_)) { 244 // 1. Let for be the value of el's' for attribute. 245 auto for_ = attribute(HTML::AttributeNames::for_); 246 247 // 2. Let event be the value of el's event attribute. 248 auto event = attribute(HTML::AttributeNames::event); 249 250 // 3. Strip leading and trailing ASCII whitespace from event and for. 251 for_ = for_.trim(Infra::ASCII_WHITESPACE); 252 event = event.trim(Infra::ASCII_WHITESPACE); 253 254 // 4. If for is not an ASCII case-insensitive match for the string "window", then return. 255 if (!Infra::is_ascii_case_insensitive_match(for_, "window"sv)) { 256 dbgln("HTMLScriptElement: Refusing to run classic script because the provided 'for' attribute is not equal to 'window'"); 257 return; 258 } 259 260 // 5. If event is not an ASCII case-insensitive match for either the string "onload" or the string "onload()", then return. 261 if (!Infra::is_ascii_case_insensitive_match(event, "onload"sv) 262 && !Infra::is_ascii_case_insensitive_match(event, "onload()"sv)) { 263 dbgln("HTMLScriptElement: Refusing to run classic script because the provided 'event' attribute is not equal to 'onload' or 'onload()'"); 264 return; 265 } 266 } 267 268 // FIXME: 21. If el has a charset attribute, then let encoding be the result of getting an encoding from the value of the charset attribute. 269 // If el does not have a charset attribute, or if getting an encoding failed, then let encoding be el's node document's the encoding. 270 271 // FIXME: 22. Let classic script CORS setting be the current state of el's crossorigin content attribute. 272 273 // FIXME: 23. Let module script credentials mode be the CORS settings attribute credentials mode for el's crossorigin content attribute. 274 275 // FIXME: 24. Let cryptographic nonce be el's [[CryptographicNonce]] internal slot's value. 276 277 // FIXME: 25. If el has an integrity attribute, then let integrity metadata be that attribute's value. 278 // Otherwise, let integrity metadata be the empty string. 279 280 // FIXME: 26. Let referrer policy be the current state of el's referrerpolicy content attribute. 281 282 // FIXME: 27. Let parser metadata be "parser-inserted" if el is parser-inserted, and "not-parser-inserted" otherwise. 283 284 // FIXME: 28. Let options be a script fetch options whose cryptographic nonce is cryptographic nonce, 285 // integrity metadata is integrity metadata, parser metadata is parser metadata, 286 // credentials mode is module script credentials mode, and referrer policy is referrer policy. 287 288 // 29. Let settings object be el's node document's relevant settings object. 289 auto& settings_object = document().relevant_settings_object(); 290 291 // 30. If el has a src content attribute, then: 292 if (has_attribute(HTML::AttributeNames::src)) { 293 // 1. If el's type is "importmap", 294 if (m_script_type == ScriptType::ImportMap) { 295 // then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return. 296 queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { 297 dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); 298 }); 299 return; 300 } 301 302 // 2. Let src be the value of el's src attribute. 303 auto src = attribute(HTML::AttributeNames::src); 304 305 // 3. If src is the empty string, then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return. 306 if (src.is_empty()) { 307 dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty."); 308 queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { 309 dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); 310 }); 311 return; 312 } 313 314 // 4. Set el's from an external file to true. 315 m_from_an_external_file = true; 316 317 // 5. Parse src relative to el's node document. 318 auto url = document().parse_url(src); 319 320 // 6. If the previous step failed, then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return. Otherwise, let url be the resulting URL record. 321 if (!url.is_valid()) { 322 dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url); 323 queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { 324 dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); 325 }); 326 return; 327 } 328 329 // FIXME: 7. If el is potentially render-blocking, then block rendering on el. 330 331 // 8. Set el's delaying the load event to true. 332 begin_delaying_document_load_event(*m_preparation_time_document); 333 334 // FIXME: 9. If el is currently render-blocking, then set options's render-blocking to true. 335 336 // 10. Let onComplete given result be the following steps: 337 // NOTE: This is weaved into usages of onComplete below. It would be better if we set it up here. 338 339 // 11. Switch on el's type: 340 // -> "classic" 341 if (m_script_type == ScriptType::Classic) { 342 // Fetch a classic script given url, settings object, options, classic script CORS setting, encoding, and onComplete. 343 344 // FIXME: This is ad-hoc. 345 auto request = LoadRequest::create_for_url_on_page(url, document().page()); 346 auto resource = ResourceLoader::the().load_resource(Resource::Type::Generic, request); 347 set_resource(resource); 348 } 349 // -> "module" 350 else if (m_script_type == ScriptType::Module) { 351 // Fetch an external module script graph given url, settings object, options, and onComplete. 352 // FIXME: Pass options. 353 fetch_external_module_script_graph(url, settings_object, [this](auto* result) { 354 // 1. Mark as ready el given result. 355 if (!result) 356 mark_as_ready(ResultState::Null {}); 357 else 358 mark_as_ready(Result(*result)); 359 }); 360 } 361 } 362 363 // 31. If el does not have a src content attribute: 364 if (!has_attribute(HTML::AttributeNames::src)) { 365 // Let base URL be el's node document's document base URL. 366 auto base_url = document().base_url(); 367 368 // 2. Switch on el's type: 369 // -> "classic" 370 if (m_script_type == ScriptType::Classic) { 371 // 1. Let script be the result of creating a classic script using source text, settings object, base URL, and options. 372 // FIXME: Pass options. 373 auto script = ClassicScript::create(m_document->url().to_deprecated_string(), source_text, settings_object, base_url, m_source_line_number); 374 375 // 2. Mark as ready el given script. 376 mark_as_ready(Result(move(script))); 377 } 378 // -> "module" 379 else if (m_script_type == ScriptType::Module) { 380 // 1. Set el's delaying the load event to true. 381 begin_delaying_document_load_event(*m_preparation_time_document); 382 383 // 2. Fetch an inline module script graph, given source text, base URL, settings object, options, and with the following steps given result: 384 // FIXME: Pass options 385 fetch_inline_module_script_graph(m_document->url().to_deprecated_string(), source_text, base_url, document().relevant_settings_object(), [this](auto* result) { 386 // 1. Mark as ready el given result. 387 if (!result) 388 mark_as_ready(ResultState::Null {}); 389 else 390 mark_as_ready(Result(*result)); 391 }); 392 } 393 // -> "importmap" 394 else if (m_script_type == ScriptType::ImportMap) { 395 // FIXME: 1. If el's relevant global object's import maps allowed is false, then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return. 396 397 // FIXME: 2. Set el's relevant global object's import maps allowed to false. 398 399 // FIXME: 3. Let result be the result of creating an import map parse result given source text and base URL. 400 401 // FIXME: 4. Mark as ready el given result. 402 } 403 } 404 405 // 32. If el's type is "classic" and el has a src attribute, or el's type is "module": 406 if ((m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::src)) || m_script_type == ScriptType::Module) { 407 // 1. Assert: el's result is "uninitialized". 408 // FIXME: I believe this step to be a spec bug, and it should be removed: https://github.com/whatwg/html/issues/8534 409 410 // 2. If el has an async attribute or el's force async is true: 411 if (has_attribute(HTML::AttributeNames::async) || m_force_async) { 412 // 1. Let scripts be el's preparation-time document's set of scripts that will execute as soon as possible. 413 // 2. Append el to scripts. 414 m_preparation_time_document->scripts_to_execute_as_soon_as_possible().append(*this); 415 416 // 3. Set el's steps to run when the result is ready to the following: 417 m_steps_to_run_when_the_result_is_ready = [this] { 418 // 1. Execute the script element el. 419 execute_script(); 420 421 // 2. Remove el from scripts. 422 m_preparation_time_document->scripts_to_execute_as_soon_as_possible().remove_first_matching([this](auto& entry) { 423 return entry.ptr() == this; 424 }); 425 }; 426 } 427 428 // 3. Otherwise, if el is not parser-inserted: 429 else if (!is_parser_inserted()) { 430 // 1. Let scripts be el's preparation-time document's list of scripts that will execute in order as soon as possible. 431 // 2. Append el to scripts. 432 m_preparation_time_document->scripts_to_execute_in_order_as_soon_as_possible().append(*this); 433 434 // 3. Set el's steps to run when the result is ready to the following: 435 m_steps_to_run_when_the_result_is_ready = [this] { 436 auto& scripts = m_preparation_time_document->scripts_to_execute_in_order_as_soon_as_possible(); 437 // 1. If scripts[0] is not el, then abort these steps. 438 if (scripts[0] != this) 439 return; 440 441 // 2. While scripts is not empty, and scripts[0]'s result is not "uninitialized": 442 while (!scripts.is_empty() && !scripts[0]->m_result.has<ResultState::Uninitialized>()) { 443 // 1. Execute the script element scripts[0]. 444 scripts[0]->execute_script(); 445 446 // 2. Remove scripts[0]. 447 scripts.take_first(); 448 } 449 }; 450 } 451 452 // 4. Otherwise, if el has a defer attribute or el's type is "module": 453 else if (has_attribute(HTML::AttributeNames::defer) || m_script_type == ScriptType::Module) { 454 // 1. Append el to its parser document's list of scripts that will execute when the document has finished parsing. 455 m_parser_document->scripts_to_execute_when_parsing_has_finished().append(*this); 456 457 // 2. Set el's steps to run when the result is ready to the following: 458 m_steps_to_run_when_the_result_is_ready = [this] { 459 // set el's ready to be parser-executed to true. (The parser will handle executing the script.) 460 m_ready_to_be_parser_executed = true; 461 }; 462 } 463 464 // 5. Otherwise: 465 else { 466 // 1. Set el's parser document's pending parsing-blocking script to el. 467 m_parser_document->set_pending_parsing_blocking_script({}, this); 468 469 // FIXME: 2. Block rendering on el. 470 471 // 3. Set el's steps to run when the result is ready to the following: 472 m_steps_to_run_when_the_result_is_ready = [this] { 473 // set el's ready to be parser-executed to true. (The parser will handle executing the script.) 474 m_ready_to_be_parser_executed = true; 475 }; 476 } 477 } 478 479 // 33. Otherwise: 480 else { 481 // 1. Assert: el's result is not "uninitialized". 482 VERIFY(!m_result.has<ResultState::Uninitialized>()); 483 484 // 2. If all of the following are true: 485 // - el's type is "classic"; 486 // - el is parser-inserted; 487 // - el's parser document has a style sheet that is blocking scripts; and 488 // FIXME: - either the parser that created el is an XML parser, or it's an HTML parser whose script nesting level is not greater than one, 489 // then: 490 if (m_script_type == ScriptType::Classic 491 && is_parser_inserted() 492 && m_parser_document->has_a_style_sheet_that_is_blocking_scripts()) { 493 // 1. Set el's parser document's pending parsing-blocking script to el. 494 m_parser_document->set_pending_parsing_blocking_script({}, this); 495 496 // 2. Set el's ready to be parser-executed to true. (The parser will handle executing the script.) 497 m_ready_to_be_parser_executed = true; 498 } 499 500 // 3. Otherwise, 501 else { 502 // immediately execute the script element el, even if other scripts are already executing. 503 execute_script(); 504 } 505 } 506} 507 508void HTMLScriptElement::resource_did_load() 509{ 510 // FIXME: This is all ad-hoc and needs work. 511 512 auto data = resource()->encoded_data(); 513 514 // If the resource has an explicit encoding (i.e from a HTTP Content-Type header) 515 // we have to re-encode it to UTF-8. 516 if (resource()->has_encoding()) { 517 if (auto codec = TextCodec::decoder_for(resource()->encoding().value()); codec.has_value()) { 518 data = codec->to_utf8(data).release_value_but_fixme_should_propagate_errors().to_deprecated_string().to_byte_buffer(); 519 } 520 } 521 522 auto script = ClassicScript::create(resource()->url().to_deprecated_string(), data, document().relevant_settings_object(), AK::URL()); 523 524 // When the chosen algorithm asynchronously completes, set the script's script to the result. At that time, the script is ready. 525 mark_as_ready(Result(script)); 526} 527 528void HTMLScriptElement::resource_did_fail() 529{ 530 m_failed_to_load = true; 531 dbgln("HONK! Failed to load script, but ready nonetheless."); 532 m_result = ResultState::Null {}; 533 mark_as_ready(m_result); 534} 535 536void HTMLScriptElement::inserted() 537{ 538 if (!is_parser_inserted()) { 539 // FIXME: Only do this if the element was previously not connected. 540 if (is_connected()) { 541 prepare_script(); 542 } 543 } 544 HTMLElement::inserted(); 545} 546 547// https://html.spec.whatwg.org/multipage/scripting.html#mark-as-ready 548void HTMLScriptElement::mark_as_ready(Result result) 549{ 550 // 1. Set el's result to result. 551 m_result = move(result); 552 553 // 2. If el's steps to run when the result is ready are not null, then run them. 554 if (m_steps_to_run_when_the_result_is_ready) 555 m_steps_to_run_when_the_result_is_ready(); 556 557 // 3. Set el's steps to run when the result is ready to null. 558 m_steps_to_run_when_the_result_is_ready = nullptr; 559 560 // 4. Set el's delaying the load event to false. 561 m_document_load_event_delayer.clear(); 562} 563 564void HTMLScriptElement::unmark_as_already_started(Badge<DOM::Range>) 565{ 566 m_already_started = false; 567} 568 569void HTMLScriptElement::unmark_as_parser_inserted(Badge<DOM::Range>) 570{ 571 m_parser_document = nullptr; 572} 573 574}