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

Unified Diff: extensions/renderer/module_system.cc

Issue 783333002: Throw JavaScript error instead of CHECK when this in privates is invalid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add elaborate error message for undefined Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/module_system.cc
diff --git a/extensions/renderer/module_system.cc b/extensions/renderer/module_system.cc
index 1e121051e767869bf0689ae4fc8c06276289edec..270e5426b10b73844f0a3d1bc0302ac36912a655 100644
--- a/extensions/renderer/module_system.cc
+++ b/extensions/renderer/module_system.cc
@@ -563,8 +563,14 @@ v8::Handle<v8::String> ModuleSystem::WrapSource(v8::Handle<v8::String> source) {
void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_EQ(1, args.Length());
- CHECK(args[0]->IsObject());
- CHECK(!args[0]->IsNull());
+ if (!args[0]->IsObject() || args[0]->IsNull()) {
+ GetIsolate()->ThrowException(v8::Exception::TypeError(
+ args[0]->IsUndefined() ?
not at google - send to devlin 2014/12/08 22:48:11 I think the ternary here looks pretty weird. I had
robwu 2014/12/08 22:51:27 Would it help if I put the ? and : at the start of
robwu 2014/12/08 23:08:38 Done (I put ? and : in front of the line and ran g
+ "Method called without a valid receiver (this)."
+ "Did you forget to call .bind()?" :
+ "Invalid invocation: this is not an object!"));
+ return;
+ }
v8::Local<v8::Object> obj = args[0].As<v8::Object>();
v8::Local<v8::String> privates_key =
v8::String::NewFromUtf8(GetIsolate(), "privates");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698