Index: third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp |
diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp |
index b7743e59b5feb1689beb7bb013f0c9a0770dfc44..4d2c6f10b6428927b613355010abc027c280d6a6 100644 |
--- a/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp |
+++ b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp |
@@ -29,16 +29,52 @@ ScriptPromise MainThreadWorklet::addModule(ScriptState* script_state, |
"This frame is already detached")); |
} |
+ // Step 1: "Let promise be a new promise." |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
+ ScriptPromise promise = resolver->Promise(); |
+ |
+ // Step 2: "Let worklet be the current Worklet." |
+ // |this| is the current Worklet. |
+ |
+ // Step 3: "Let moduleURLRecord be the result of parsing the moduleURL |
+ // argument relative to the relevant settings object of this." |
KURL module_url_record = GetExecutionContext()->CompleteURL(module_url); |
+ |
+ // Step 4: "If moduleURLRecord is failure, then reject promise with a |
+ // "SyntaxError" DOMException and return promise." |
if (!module_url_record.IsValid()) { |
- return ScriptPromise::RejectWithDOMException( |
- script_state, |
- DOMException::Create(kSyntaxError, |
- "'" + module_url + "' is not a valid URL.")); |
+ resolver->Reject(DOMException::Create( |
+ kSyntaxError, "'" + module_url + "' is not a valid URL.")); |
+ return promise; |
} |
- ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
- ScriptPromise promise = resolver->Promise(); |
+ // Step 5: "Return promise, and then continue running this algorithm in |
+ // parallel." |
+ // TODO(nhiroki): Make the following sequence async. |
+ |
+ // Step 6: "Let credentialOptions be the credentials member of options." |
+ // TODO(nhiroki): Implement credentialOptions (https://crbug.com/710837). |
+ |
+ // Step 7: "Let outsideSettings be the relevant settings object of this." |
+ // TODO(nhiroki): outsideSettings will be used for posting a task to the |
+ // document's responsible event loop. We could use a task runner for the |
+ // purpose. |
+ |
+ // Step 8: "Let moduleResponsesMap be worklet's module responses map." |
+ // TODO(nhiroki): Implement moduleResponsesMap (https://crbug.com/627945). |
+ |
+ // Step 9: "Let workletGlobalScopeType be worklet's worklet global scope |
+ // type." |
+ // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet). |
+ |
+ // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following |
+ // steps:" |
+ // 10.1: "Create a WorkletGlobalScope given workletGlobalScopeType, |
+ // moduleResponsesMap, and outsideSettings." |
+ // 10.2: "Add the WorkletGlobalScope to worklet's WorkletGlobalScopes." |
+ // "Depending on the type of worklet the user agent may create additional |
+ // WorkletGlobalScopes at this time." |
+ // TODO(nhiroki): Create WorkletGlobalScopes at this point. |
// Step 11: "Let pendingTaskStruct be a new pending tasks struct with counter |
// initialized to the length of worklet's WorkletGlobalScopes." |