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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp

Issue 2244203002: Fix "report the exception" in Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Took approach 7 and cleanup Created 4 years, 4 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
Index: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
index 2485dc2cc6f7846ab327bec575bf0c1116872a49..d99a1b39b617955906c2502c729463008490b69e 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
@@ -588,4 +588,25 @@ void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler)
cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(now), CachedMetadataHandler::SendToPlatform);
}
+void V8ScriptRunner::throwException(v8::Isolate* isolate, v8::Local<v8::Value> exception, const v8::ScriptOrigin& origin)
+{
+ // Use V8ThrowException instead of this function unless absolutely needed.
Yuki 2016/08/22 06:42:08 Thanks for the caution, but it's better to put thi
+ // In order for the current TryCatch to catch this exception and
+ // call MessageCallback when SetVerbose(true), create a v8::Function
+ // that calls isolate->throwException().
+ // Unlike throwStackOverflowExceptionIfNeeded(), create a temporary Script
+ // with the specified ScriptOrigin. When the exception was created but not
+ // thrown yet, the ScriptOrigin of the thrower is set to the exception.
+ // v8::Function::New() has empty ScriptOrigin, and thus the exception will
+ // be "muted" (sanitized in our terminology) if CORS does not allow.
+ // https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error
+ v8::Local<v8::Script> script = compileWithoutOptions(
+ V8CompileHistogram::Cacheability::Noncacheable, isolate,
+ v8AtomicString(isolate, "((e) => { throw e; })"), origin)
+ .ToLocalChecked();
+ v8::Local<v8::Function> thrower = runCompiledInternalScript(isolate, script)
haraken 2016/08/22 06:36:47 It's silly that we have to compile the script ever
+ .ToLocalChecked().As<v8::Function>();
+ callInternalFunction(thrower, thrower, 1, &exception, isolate);
haraken 2016/08/22 06:36:47 I'd prefer creating an array. v8::Local<v8::Value
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698