Commit 30dcdbbe authored by eric@webkit.org's avatar eric@webkit.org

2010-01-22 Kent Hansen <kent.hansen@nokia.com>

        Reviewed by Darin Adler.

        Object.getOwnPropertyDescriptor(window) returns descriptors for properties in the prototype chain
        https://bugs.webkit.org/show_bug.cgi?id=33948

        Even though prototype properties are proxied by JSDOMWindow::getOwnPropertySlot(),
        that proxying should not be performed by JSDOMWindow::getOwnPropertyDescriptor().

        This makes getOwnPropertyDescriptor() consistent with getOwnPropertyNames().

        Test: fast/dom/Window/window-property-descriptors.html

        * bindings/js/JSDOMWindowCustom.cpp:
        (WebCore::JSDOMWindow::getOwnPropertyDescriptor):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53706 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0f9a74b8
description("Test Object.getOwnPropertyDescriptor on window object.");
var __skip__ = {
"__skip__" : 1,
"opener" : 1, // Work around DumpRenderTree bug where previous tests add window properties
"Components" : 1, // Work around Firefox exception
// Don't log DumpRenderTree injected objects
"layoutTestController" : 1, // Work around http://bugs.webkit.org/show_bug.cgi?id=11373
"GCController" : 1,
"accessibilityController" : 1,
"appleScriptController" : 1,
"eventSender" : 1,
"navigationController" : 1,
"objCController" : 1,
"objCPlugin" : 1,
"objCPluginFunction" : 1,
"plainText" : 1,
"textInputController" : 1,
// Ignore these properties because they do not exist in all implementations. They will be tested separately
"WebGLRenderingContext" : 1,
"WebGLArrayBuffer" : 1,
"WebGLByteArray" : 1,
"WebGLFloatArray" : 1,
"WebGLIntArray" : 1,
"WebGLShortArray" : 1,
"WebGLUnsignedByteArray" : 1,
"WebGLUnsignedIntArray" : 1,
"WebGLUnsignedShortArray" : 1
};
var windowPropertyNames = Object.getOwnPropertyNames(window)
.filter(function(name) { return !__skip__[name]; })
.sort();
for (var i = 0; i < windowPropertyNames.length; ++i)
shouldBe("typeof Object.getOwnPropertyDescriptor(window, '" + windowPropertyNames[i] + "')", "'object'");
// Properties in the prototype should not return descriptors
var protoPropertySet = {};
for (var o = window.__proto__; o; o = o.__proto__) {
var names = Object.getOwnPropertyNames(o);
for (var i = 0; i < names.length; ++i)
protoPropertySet[names[i]] = true;
}
var protoPropertyNames = [];
for (var name in protoPropertySet)
protoPropertyNames.push(name);
protoPropertyNames.sort();
for (var i = 0; i < protoPropertyNames.length; ++i)
shouldBeUndefined("Object.getOwnPropertyDescriptor(window, '" + protoPropertyNames[i] + "')");
var successfullyParsed = true;
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/window-property-descriptors.js"></script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
2010-01-22 Kent Hansen <kent.hansen@nokia.com>
Reviewed by Darin Adler.
Object.getOwnPropertyDescriptor(window) returns descriptors for properties in the prototype chain
https://bugs.webkit.org/show_bug.cgi?id=33948
Even though prototype properties are proxied by JSDOMWindow::getOwnPropertySlot(),
that proxying should not be performed by JSDOMWindow::getOwnPropertyDescriptor().
This makes getOwnPropertyDescriptor() consistent with getOwnPropertyNames().
Test: fast/dom/Window/window-property-descriptors.html
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::getOwnPropertyDescriptor):
2010-01-22 Girish Ramakrishnan <girish@forwardbias.in>
Reviewed by Simon Hausmann.
......@@ -325,22 +325,6 @@ bool JSDOMWindow::getOwnPropertyDescriptor(ExecState* exec, const Identifier& pr
return true;
}
// We need this code here because otherwise JSDOMWindowBase will stop the search before we even get to the
// prototype due to the blanket same origin (allowsAccessFrom) check at the end of getOwnPropertySlot.
// Also, it's important to get the implementation straight out of the DOMWindow prototype regardless of
// what prototype is actually set on this object.
entry = JSDOMWindowPrototype::s_info.propHashTable(exec)->entry(exec, propertyName);
if (entry) {
if (entry->attributes() & Function) {
if (entry->function() == jsDOMWindowPrototypeFunctionShowModalDialog) {
if (!DOMWindow::canShowModalDialog(impl()->frame())) {
descriptor.setUndefined();
return true;
}
}
}
}
entry = JSDOMWindow::s_info.propHashTable(exec)->entry(exec, propertyName);
if (entry) {
PropertySlot slot;
......@@ -361,14 +345,6 @@ bool JSDOMWindow::getOwnPropertyDescriptor(ExecState* exec, const Identifier& pr
return true;
}
// Do prototype lookup early so that functions and attributes in the prototype can have
// precedence over the index and name getters.
JSValue proto = prototype();
if (proto.isObject()) {
if (asObject(proto)->getPropertyDescriptor(exec, propertyName, descriptor))
return true;
}
bool ok;
unsigned i = propertyName.toArrayIndex(&ok);
if (ok && i < impl()->frame()->tree()->childCount()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment