Hello michaeln, steveblock,
I'd like you to do a code review. Please execute
g4 diff -c 9007880
or point your web browser to
http://mondrian/9007880
to review the following code:
Change 9007880 by [EMAIL PROTECTED] on 2008/11/14 16:53:26 *pending*
Fix for Phil's crash on FF: throw an exception if we detect a 'call by
reference' to a Gears function.
R=michaeln,steveblock
[EMAIL PROTECTED]
DELTA=22 (21 added, 0 deleted, 1 changed)
OCL=9007880
Affected files ...
...
//depot/googleclient/gears/opensource/gears/base/common/js_runner_ff_marshaling.cc#12
edit
22 delta lines: 21 added, 0 deleted, 1 changed
Also consider running:
g4 lint -c 9007880
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 9007880 by [EMAIL PROTECTED] on 2008/11/14 16:53:26 *pending*
Fix for Phil's crash on FF: throw an exception if we detect a 'call by
reference' to a Gears function.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/base/common/js_runner_ff_marshaling.cc#12
edit
====
//depot/googleclient/gears/opensource/gears/base/common/js_runner_ff_marshaling.cc#12
-
c:\Gears/googleclient/gears/opensource/gears/base/common/js_runner_ff_marshaling.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/base/common/js_runner_ff_marshaling.cc
2008-11-14 16:54:40.000000000 +0000
+++ googleclient/gears/opensource/gears/base/common/js_runner_ff_marshaling.cc
2008-11-14 16:51:42.000000000 +0000
@@ -532,7 +532,28 @@
JsWrapperDataForInstance *instance_data =
static_cast<JsWrapperDataForInstance*>(JS_GetPrivate(cx, instance_obj));
- assert(instance_data);
+ if (!instance_data) {
+ // We can get here in the case of a Gears method being invoked via
+ // a reference, as in the example below:
+ // someModule = google.gears.factory.create('beta.someModule');
+ // var reference = someModule.someMethod;
+ // reference();
+ JSRuntime *runtime = JS_GetRuntime(cx);
+ assert(runtime);
+ // Creating a new JsRunner just for the purpose of creating a new Error
+ // object may seem somewhat wasteful, but this is a relatively exotic
+ // situation so, in practice, it will make little difference.
+ scoped_ptr<JsRunnerInterface> js_runner(NewJsRunner(runtime));
+ assert(js_runner.get());
+ scoped_ptr<JsObject> error_object(js_runner->NewError(
+ STRING16(L"Member function called without a Gears object.")));
+ if (error_object.get()) {
+ JS_BeginRequest(cx);
+ JS_SetPendingException(cx, error_object->token());
+ JS_EndRequest(cx);
+ }
+ return JS_FALSE;
+ }
assert(instance_data->header.type == INSTANCE_JSOBJECT);
assert(instance_data->module);
assert(function_data->dispatch_id);