Commit 5aea1601 authored by nhiroki's avatar nhiroki Committed by Commit bot

Worklet: Add step comments in MainThreadWorklet::addModule()

Spec: https://drafts.css-houdini.org/worklets/#dom-worklet-addmodule

BUG=627945

Review-Url: https://codereview.chromium.org/2851693002
Cr-Commit-Position: refs/heads/master@{#467999}
parent aab6bf24
...@@ -29,16 +29,52 @@ ScriptPromise MainThreadWorklet::addModule(ScriptState* script_state, ...@@ -29,16 +29,52 @@ ScriptPromise MainThreadWorklet::addModule(ScriptState* script_state,
"This frame is already detached")); "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); 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()) { if (!module_url_record.IsValid()) {
return ScriptPromise::RejectWithDOMException( resolver->Reject(DOMException::Create(
script_state, kSyntaxError, "'" + module_url + "' is not a valid URL."));
DOMException::Create(kSyntaxError, return promise;
"'" + module_url + "' is not a valid URL."));
} }
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); // Step 5: "Return promise, and then continue running this algorithm in
ScriptPromise promise = resolver->Promise(); // 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 // Step 11: "Let pendingTaskStruct be a new pending tasks struct with counter
// initialized to the length of worklet's WorkletGlobalScopes." // initialized to the length of worklet's WorkletGlobalScopes."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment