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

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: s/this/receiver/ 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..5a180b458583040c3ee433656abb7b1df74f3f89 100644
--- a/extensions/renderer/module_system.cc
+++ b/extensions/renderer/module_system.cc
@@ -563,8 +563,15 @@ 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(v8::String::NewFromUtf8(GetIsolate(),
+ args[0]->IsUndefined()
+ ? "Method called without a valid receiver (this). "
+ "Did you forget to call .bind()?"
+ : "Invalid invocation: receiver 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