Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 // TODO(hiroshige): Make them merged or consistent. | 474 // TODO(hiroshige): Make them merged or consistent. |
| 475 | 475 |
| 476 // 22.2. "Switch on the script's type:" | 476 // 22.2. "Switch on the script's type:" |
| 477 switch (GetScriptType()) { | 477 switch (GetScriptType()) { |
| 478 // - "classic": | 478 // - "classic": |
| 479 case ScriptType::kClassic: | 479 case ScriptType::kClassic: |
| 480 // TODO(hiroshige): Clarify how Step 22.2 is implemented for "classic". | 480 // TODO(hiroshige): Clarify how Step 22.2 is implemented for "classic". |
| 481 break; | 481 break; |
| 482 | 482 |
| 483 // - "module": | 483 // - "module": |
| 484 case ScriptType::kModule: | 484 case ScriptType::kModule: { |
| 485 // TODO(hiroshige): Implement inline module scripts. | 485 // Dup of FetchScript() logic. |
| 486 element_document.AddConsoleMessage(ConsoleMessage::Create( | 486 |
| 487 kJSMessageSource, kErrorMessageLevel, | 487 // 15. "Let CORS setting be the current state of the element's |
| 488 "Inline module script is not yet supported", | 488 // crossorigin content attribute." |
| 489 SourceLocation::Create(element_document.Url().GetString(), | 489 CrossOriginAttributeValue cross_origin = |
| 490 script_start_position.line_.OneBasedInt(), | 490 GetCrossOriginAttributeValue(element_->CrossOriginAttributeValue()); |
| 491 script_start_position.column_.OneBasedInt(), | 491 |
| 492 nullptr))); | 492 // 16. "Let module script credentials mode be determined by switching |
| 493 return false; | 493 // on CORS setting:" |
| 494 WebURLRequest::FetchCredentialsMode credentials_mode = | |
| 495 WebURLRequest::kFetchCredentialsModeOmit; | |
| 496 switch (cross_origin) { | |
| 497 case kCrossOriginAttributeNotSet: | |
| 498 credentials_mode = WebURLRequest::kFetchCredentialsModeOmit; | |
| 499 break; | |
| 500 case kCrossOriginAttributeAnonymous: | |
| 501 credentials_mode = WebURLRequest::kFetchCredentialsModeSameOrigin; | |
| 502 break; | |
| 503 case kCrossOriginAttributeUseCredentials: | |
| 504 credentials_mode = WebURLRequest::kFetchCredentialsModeInclude; | |
| 505 break; | |
| 506 } | |
| 507 // 17. "If the script element has a nonce attribute, | |
| 508 // then let cryptographic nonce be that attribute's value. | |
| 509 // Otherwise, let cryptographic nonce be the empty string." | |
| 510 String nonce; | |
| 511 if (element_->IsNonceableElement()) | |
| 512 nonce = element_->nonce(); | |
| 513 | |
| 514 // 19. "Let parser state be "parser-inserted" | |
| 515 // if the script element has been flagged as "parser-inserted", | |
| 516 // and "not parser-inserted" otherwise." | |
| 517 ParserDisposition parser_state = | |
| 518 IsParserInserted() ? kParserInserted : kNotParserInserted; | |
| 519 | |
| 520 // End of dup. | |
| 521 KURL script_url = | |
| 522 (!element_document.IsInDocumentWrite() && parser_inserted_) | |
| 523 ? element_document.Url() | |
| 524 : KURL(); | |
| 525 | |
| 526 // 1. Let base URL be the script element's node document's document | |
| 527 // base URL. | |
| 528 KURL base_url = element_document.BaseURL(); | |
| 529 | |
| 530 // 2. Let script be the result of creating a module script using | |
| 531 // source text, settings, base URL, cryptographic nonce, parser state, | |
| 532 // and module script credentials mode. | |
| 533 Modulator* modulator = Modulator::From( | |
| 534 ToScriptStateForMainWorld(element_document.GetFrame())); | |
| 535 ScriptModule record = modulator->CompileModule( | |
| 536 ScriptContent(), base_url, kSharableCrossOrigin); | |
| 537 // 3. If this returns null, set the script's script to null and abort | |
| 538 // these substeps; the script is ready. | |
| 539 if (record.IsNull()) { | |
| 540 return false; | |
| 541 } | |
| 542 | |
| 543 ModuleScript* script = ModuleScript::Create( | |
| 544 modulator, record, base_url, nonce, parser_state, credentials_mode); | |
| 545 | |
| 546 // 4. Fetch the descendants of script (using an empty ancestor list). | |
| 547 // When this asynchronously completes, set the script's script to | |
| 548 // the result. At that time, the script is ready. | |
| 549 DCHECK(!module_tree_client_); | |
| 550 module_tree_client_ = ModulePendingScriptTreeClient::Create(); | |
| 551 modulator->FetchDescendantsForInlineScript(script, module_tree_client_); | |
|
hiroshige
2017/04/26 04:54:59
[not specced]
This CL jumps to Step 5. of
https://
| |
| 552 } | |
| 494 } | 553 } |
| 495 } | 554 } |
| 496 | 555 |
| 497 // [Intervention] | 556 // [Intervention] |
| 498 // Since the asynchronous, low priority fetch for doc.written blocked | 557 // Since the asynchronous, low priority fetch for doc.written blocked |
| 499 // script is not for execution, return early from here. Watch for its | 558 // script is not for execution, return early from here. Watch for its |
| 500 // completion to be able to remove it from the memory cache. | 559 // completion to be able to remove it from the memory cache. |
| 501 if (GetScriptType() == ScriptType::kClassic && | 560 if (GetScriptType() == ScriptType::kClassic && |
| 502 document_write_intervention_ == | 561 document_write_intervention_ == |
| 503 DocumentWriteIntervention::kFetchDocWrittenScriptDeferIdle) { | 562 DocumentWriteIntervention::kFetchDocWrittenScriptDeferIdle) { |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 // then abort these steps at this point. The script is not executed. | 1031 // then abort these steps at this point. The script is not executed. |
| 973 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || | 1032 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || |
| 974 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); | 1033 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); |
| 975 } | 1034 } |
| 976 | 1035 |
| 977 String ScriptLoader::ScriptContent() const { | 1036 String ScriptLoader::ScriptContent() const { |
| 978 return element_->TextFromChildren(); | 1037 return element_->TextFromChildren(); |
| 979 } | 1038 } |
| 980 | 1039 |
| 981 } // namespace blink | 1040 } // namespace blink |
| OLD | NEW |