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

Issue 783333002: Throw JavaScript error instead of CHECK when this in privates is invalid (Closed)

Created:
6 years ago by robwu
Modified:
6 years ago
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Throw JavaScript error instead of CHECK when this is invalid. The extension system frequently uses privates(this). this can easily be set to a non-object or a null value by accident, so throw an exception instead of terminating the renderer. Example: var addListener = chrome.runtime.onMessage.addListener; addListener(function() { }); // In strict mode, the "this" of addListener is undefined, which // causes the CHECK to be triggered and the renderer to be killed: module_system.cc(563)] Check failed: args[0]->IsObject() R=kalman@chromium.org TEST=manually; ran Chrome, installed any extension and pasted the previous code snippet in the console of the extension, and observed that a JavaScript error was thrown (in the console). Committed: https://crrev.com/5c641eddb3b30f6fe62c972ae4bfcb88e8985714 Cr-Commit-Position: refs/heads/master@{#307385}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Add elaborate error message for undefined #

Total comments: 3

Patch Set 3 : Improve code formatting + fix v8 API invocation #

Total comments: 1

Patch Set 4 : s/this/receiver/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -2 lines) Patch
M extensions/renderer/module_system.cc View 1 2 3 1 chunk +9 lines, -2 lines 0 comments Download

Messages

Total messages: 13 (1 generated)
robwu
Bug report: https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/05jW7aap1s8/EB8uJLHqrakJ
6 years ago (2014-12-08 22:17:32 UTC) #1
not at google - send to devlin
https://codereview.chromium.org/783333002/diff/1/extensions/renderer/module_system.cc File extensions/renderer/module_system.cc (right): https://codereview.chromium.org/783333002/diff/1/extensions/renderer/module_system.cc#newcode570 extensions/renderer/module_system.cc:570: return; Good catch, I think this is the right ...
6 years ago (2014-12-08 22:29:11 UTC) #2
robwu
https://codereview.chromium.org/783333002/diff/1/extensions/renderer/module_system.cc File extensions/renderer/module_system.cc (right): https://codereview.chromium.org/783333002/diff/1/extensions/renderer/module_system.cc#newcode570 extensions/renderer/module_system.cc:570: return; On 2014/12/08 22:29:11, kalman wrote: > Good catch, ...
6 years ago (2014-12-08 22:39:24 UTC) #3
not at google - send to devlin
lgtm https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc File extensions/renderer/module_system.cc (right): https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc#newcode568 extensions/renderer/module_system.cc:568: args[0]->IsUndefined() ? I think the ternary here looks ...
6 years ago (2014-12-08 22:48:14 UTC) #4
robwu
https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc File extensions/renderer/module_system.cc (right): https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc#newcode568 extensions/renderer/module_system.cc:568: args[0]->IsUndefined() ? On 2014/12/08 22:48:11, kalman wrote: > I ...
6 years ago (2014-12-08 22:51:28 UTC) #5
not at google - send to devlin
On 2014/12/08 22:51:28, robwu wrote: > https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc > File extensions/renderer/module_system.cc (right): > > https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc#newcode568 > ...
6 years ago (2014-12-08 22:59:38 UTC) #6
robwu
https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc File extensions/renderer/module_system.cc (right): https://codereview.chromium.org/783333002/diff/20001/extensions/renderer/module_system.cc#newcode568 extensions/renderer/module_system.cc:568: args[0]->IsUndefined() ? On 2014/12/08 22:51:27, robwu wrote: > On ...
6 years ago (2014-12-08 23:08:38 UTC) #7
not at google - send to devlin
lgtm https://codereview.chromium.org/783333002/diff/40001/extensions/renderer/module_system.cc File extensions/renderer/module_system.cc (right): https://codereview.chromium.org/783333002/diff/40001/extensions/renderer/module_system.cc#newcode572 extensions/renderer/module_system.cc:572: : "Invalid invocation: this is not an object!"))); ...
6 years ago (2014-12-08 23:18:32 UTC) #8
robwu
6 years ago (2014-12-08 23:34:39 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/783333002/60001
6 years ago (2014-12-08 23:35:35 UTC) #11
commit-bot: I haz the power
Committed patchset #4 (id:60001)
6 years ago (2014-12-09 00:25:04 UTC) #12
commit-bot: I haz the power
6 years ago (2014-12-09 00:25:49 UTC) #13
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/5c641eddb3b30f6fe62c972ae4bfcb88e8985714
Cr-Commit-Position: refs/heads/master@{#307385}

Powered by Google App Engine
This is Rietveld 408576698