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

Issue 11635033: Basic test for interaction of Object.observe and hidden prototypes (Closed)

Created:
8 years ago by adamk
Modified:
8 years ago
Reviewers:
rossberg
CC:
v8-dev, rafaelw, arv (Not doing code reviews)
Visibility:
Public.

Description

Basic test for interaction of Object.observe and hidden prototypes The test simply shows the current behavior, not necessarily what we want the behavior to be. Committed: https://code.google.com/p/v8/source/detail?r=13272

Patch Set 1 #

Total comments: 3

Patch Set 2 : Observe proto #

Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -3 lines) Patch
M test/cctest/test-object-observe.cc View 1 3 chunks +50 lines, -3 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
adamk
8 years ago (2012-12-20 00:29:03 UTC) #1
rossberg
https://codereview.chromium.org/11635033/diff/1/test/cctest/test-object-observe.cc File test/cctest/test-object-observe.cc (right): https://codereview.chromium.org/11635033/diff/1/test/cctest/test-object-observe.cc#newcode372 test/cctest/test-object-observe.cc:372: "Object.observe(obj, function(r) { records = r });" How about ...
8 years ago (2012-12-20 15:18:35 UTC) #2
adamk
https://codereview.chromium.org/11635033/diff/1/test/cctest/test-object-observe.cc File test/cctest/test-object-observe.cc (right): https://codereview.chromium.org/11635033/diff/1/test/cctest/test-object-observe.cc#newcode372 test/cctest/test-object-observe.cc:372: "Object.observe(obj, function(r) { records = r });" On 2012/12/20 ...
8 years ago (2012-12-21 01:53:46 UTC) #3
rossberg
8 years ago (2012-12-21 11:32:11 UTC) #4
LGTM

https://codereview.chromium.org/11635033/diff/1/test/cctest/test-object-obser...
File test/cctest/test-object-observe.cc (right):

https://codereview.chromium.org/11635033/diff/1/test/cctest/test-object-obser...
test/cctest/test-object-observe.cc:372: "Object.observe(obj, function(r) {
records = r });"
On 2012/12/21 01:53:46, adamk wrote:
> On 2012/12/20 15:18:35, rossberg wrote:
> > How about also adding the dual test, where you observe the hidden prototype
> but
> > not the object?
> 
> Added. The result is...unfortunate. But in most uses of hidden prototypes I
> wouldn't expect user code to even have access to the hidden proto in order to
> call observe()!

I'm not so sure. From V8DOMWindowShell.cpp:

// To implement split-window, see
//   1) https://bugs.webkit.org/show_bug.cgi?id=17249
//   2) https://wiki.mozilla.org/Gecko:SplitWindow
//   3) https://bugzilla.mozilla.org/show_bug.cgi?id=296639
// we need to split the shadow object further into two objects:
// an outer window and an inner window. The inner window is the hidden
// prototype of the outer window. The inner window is the default
// global object of the context. A variable declared in the global
// scope is a property of the inner window.
//
// The outer window sticks to a Frame, it is exposed to JavaScript
// via window.window, window.self, window.parent, etc. The outer window
// has a security token which is the domain. The outer window cannot
// have its own properties. window.foo = 'x' is delegated to the
// inner window.
//
// When a frame navigates to a new page, the inner window is cut off
// the outer window, and the outer window identify is preserved for
// the frame. However, a new inner window is created for the new page.
// If there are JS code holds a closure to the old inner window,
// it won't be able to reach the outer window via its global object.

That seems to imply that you can get a handle on both the outer and the inner
window, and try to observe either. Now, I have always thought that this is an
abomination, and one that fundamentally violates the JS object model. But it
seems to reflect the reality of the web, and the awful requirements of the DOM
spec.

Powered by Google App Engine
This is Rietveld 408576698