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

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: haraken/yukishiino reviews 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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h ('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/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..f0a7cfcc49608736e479787b04442b6bd85dcd01 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp
@@ -588,4 +588,26 @@ 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)
+{
+ // 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
+ // Avoid compile and run scripts when API is available: crbug.com/639739
+ 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)
+ .ToLocalChecked().As<v8::Function>();
+ v8::Local<v8::Value> args[] = { exception };
+ callInternalFunction(thrower, thrower, WTF_ARRAY_LENGTH(args), args, isolate);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698