Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: third_party/WebKit/Source/core/workers/Worklet.cpp

Issue 2697243003: Worklet: Avoid import() on a detached frame (Closed)
Patch Set: move to chromium/ Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/worklet/chromium/resources/empty-worklet-script.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/workers/Worklet.cpp
diff --git a/third_party/WebKit/Source/core/workers/Worklet.cpp b/third_party/WebKit/Source/core/workers/Worklet.cpp
index fdafbedf116c18d95ad9d893c4b338f3c6eaafe3..1df2f5591d41f7561b216abb23b1eaf38c580f86 100644
--- a/third_party/WebKit/Source/core/workers/Worklet.cpp
+++ b/third_party/WebKit/Source/core/workers/Worklet.cpp
@@ -20,8 +20,11 @@ Worklet::Worklet(LocalFrame* frame)
ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) {
DCHECK(isMainThread());
- if (!isInitialized())
- initialize();
+ if (!getExecutionContext()) {
+ return ScriptPromise::rejectWithDOMException(
+ scriptState, DOMException::create(InvalidStateError,
+ "This frame is already detached"));
+ }
KURL scriptURL = getExecutionContext()->completeURL(url);
if (!scriptURL.isValid()) {
@@ -30,6 +33,9 @@ ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) {
DOMException::create(SyntaxError, "'" + url + "' is not a valid URL."));
}
+ if (!isInitialized())
+ initialize();
+
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/worklet/chromium/resources/empty-worklet-script.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698