Skip to content
Permalink
Browse files
Deprecate remaining uses of Lookup getStatic*, use HasStaticPropertyT…
…able instead.

https://bugs.webkit.org/show_bug.cgi?id=158178

Reviewed by Darin Adler.

As of bug #158059 most JSC static table property access no longer requires getOwnPropertySlot to be
overridden. Port remaining calls to the getStatic* functions in Lookup.h over to the new mechanism.

Source/JavaScriptCore:

Part 1: Switch JSGlobalObject & JSDOMWindow to use HasStaticPropertyTable.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::getOwnPropertySlot):
    - Override is still required for symbol table,
      but regular property access is now via Base::getOwnPropertySlot.
* runtime/JSGlobalObject.h:
    - add HasStaticPropertyTable to structureFlags.

Source/WebCore:

Part 1: Switch JSGlobalObject & JSDOMWindow to use HasStaticPropertyTable.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::getOwnPropertySlot):
    - getStaticPropertySlot -> Base::getOwnPropertySlot.
* bindings/js/JSPluginElementFunctions.h:
(WebCore::pluginElementCustomGetOwnPropertySlot):
    - Switch call from getStaticValueSlot to Type::getOwnPropertySlot.
      For any element where Type::hasStaticPropertyTable is true the HasStaticPropertyTable
      structure flag will also be set, so Type::getOwnPropertySlot will do the same thing.
* bindings/scripts/CodeGeneratorJS.pm:
(PrototypeHasStaticPropertyTable):
    - Was PrototypeOverridesGetOwnPropertySlot; prototypes now never need override getOwnPropertySlot so renaming accordingly.
(GenerateImplementation):
    - Removed generation of getOwnPropertySlot body for DOMGlobalObjects.
(GeneratePrototypeDeclaration):
    - For DOMGlobalObjects, set HasStaticPropertyTable instead of OverridesGetOwnPropertySlot & removed getOwnPropertySlot declaration.
(PrototypeOverridesGetOwnPropertySlot): Deleted.
    Renamed to PrototypeHasStaticPropertyTable.
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
* bindings/scripts/test/JS/JSTestGlobalObject.h:
    - Updating bindings test results.

LayoutTests:

Switch JSGlobalObject & WebCore DOM instance bindings to use HasStaticPropertyTable.

* fast/dom/unforgeable-attributes-expected.txt:
    - Progression, similar to the getOwnPropertyDescriptor test below. Previously we
      were reporting an error with a message appropriate to a disallowed value->value
      redefinition. This is actually a disallowed accessor->value reconfiguration, now
      reporting the correct error message for this.
* http/tests/security/cross-origin-window-property-access-expected.txt:
    - Newly reporting previously missing CORS error.
* js/dom/getOwnPropertyDescriptor-expected.txt:
* js/resources/getOwnPropertyDescriptor.js:
    - This test was previously incorrect - was expecting window.window property to
      reflect as a value decriptor. This now reflect as an accesor descriptor. New
      behaviour is correct per spec & matches Firefox.



Canonical link: https://commits.webkit.org/176488@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Gavin Barraclough committed Jun 6, 2016
1 parent a94983b commit f86e8a38b20476040f27e7c5f34ad1a56d745258
Showing 13 changed files with 130 additions and 89 deletions.
@@ -1,3 +1,28 @@
2016-06-05 Gavin & Ellie Barraclough <barraclough@apple.com>

Deprecate remaining uses of Lookup getStatic*, use HasStaticPropertyTable instead.
https://bugs.webkit.org/show_bug.cgi?id=158178

Reviewed by Darin Adler.

As of bug #158059 most JSC static table property access no longer requires getOwnPropertySlot to be
overridden. Port remaining calls to the getStatic* functions in Lookup.h over to the new mechanism.

Switch JSGlobalObject & WebCore DOM instance bindings to use HasStaticPropertyTable.

* fast/dom/unforgeable-attributes-expected.txt:
- Progression, similar to the getOwnPropertyDescriptor test below. Previously we
were reporting an error with a message appropriate to a disallowed value->value
redefinition. This is actually a disallowed accessor->value reconfiguration, now
reporting the correct error message for this.
* http/tests/security/cross-origin-window-property-access-expected.txt:
- Newly reporting previously missing CORS error.
* js/dom/getOwnPropertyDescriptor-expected.txt:
* js/resources/getOwnPropertyDescriptor.js:
- This test was previously incorrect - was expecting window.window property to
reflect as a value decriptor. This now reflect as an accesor descriptor. New
behaviour is correct per spec & matches Firefox.

2016-06-05 Antti Koivisto <antti@apple.com>

TextIterator should ignore non-visible frames in findPlainText
@@ -18,13 +18,13 @@ PASS Object.getOwnPropertyDescriptor(testObject, testPropertyName).configurable
Window.window
PASS testObject.hasOwnProperty(testPropertyName) is true
PASS testObject.__proto__.hasOwnProperty(testPropertyName) is false
PASS Object.defineProperty(testObject, testPropertyName, { value: 'test' }) threw exception TypeError: Attempting to change value of a readonly property..
PASS Object.defineProperty(testObject, testPropertyName, { value: 'test' }) threw exception TypeError: Attempting to change access mechanism for an unconfigurable property..
PASS Object.getOwnPropertyDescriptor(testObject, testPropertyName).configurable is false

Window.document
PASS testObject.hasOwnProperty(testPropertyName) is true
PASS testObject.__proto__.hasOwnProperty(testPropertyName) is false
PASS Object.defineProperty(testObject, testPropertyName, { value: 'test' }) threw exception TypeError: Attempting to change value of a readonly property..
PASS Object.defineProperty(testObject, testPropertyName, { value: 'test' }) threw exception TypeError: Attempting to change access mechanism for an unconfigurable property..
PASS Object.getOwnPropertyDescriptor(testObject, testPropertyName).configurable is false

Window.location
@@ -3,14 +3,15 @@ CONSOLE MESSAGE: line 1: Blocked a frame with origin "http://127.0.0.1:8000" fro
CONSOLE MESSAGE: line 1: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: line 1: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: line 1: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: line 1: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: line 15: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: line 15: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
Tests that using another window's property getter does not bypass cross-origin checks.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS Object.getOwnPropertyDescriptor(window, "document").get.call(crossOriginWindow) threw exception TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(window, "document").get.call').
PASS Object.getOwnPropertyDescriptor(window, "document").get.call(crossOriginWindow) returned undefined.
PASS Object.getOwnPropertyDescriptor(window, "name").get.call(crossOriginWindow) returned undefined.
PASS Object.getOwnPropertyDescriptor(window, "menubar").get.call(crossOriginWindow) returned undefined.
PASS Object.getOwnPropertyDescriptor(window, "scrollbars").get.call(crossOriginWindow) returned undefined.
@@ -114,9 +114,10 @@ PASS Object.getOwnPropertyDescriptor(global, 'Infinity').hasOwnProperty('get') i
PASS Object.getOwnPropertyDescriptor(global, 'Infinity').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'Infinity').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'Infinity').configurable is false
PASS Object.getOwnPropertyDescriptor(global, 'window').value is global
PASS Object.getOwnPropertyDescriptor(global, 'window').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'window').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'window').get is globalWindowGetter
PASS Object.getOwnPropertyDescriptor(global, 'window').set is undefined
PASS Object.getOwnPropertyDescriptor(global, 'window').hasOwnProperty('value') is false
PASS Object.getOwnPropertyDescriptor(global, 'window').hasOwnProperty('writable') is false
PASS Object.getOwnPropertyDescriptor(global, 'window').enumerable is true
PASS Object.getOwnPropertyDescriptor(global, 'window').configurable is false
PASS Object.getOwnPropertyDescriptor(global, 'XMLHttpRequest').value is XMLHttpRequest
@@ -41,7 +41,8 @@ descriptorShouldBe("global", "'global'", {writable: true, enumerable: true, conf
descriptorShouldBe("global", "'undefined'", {writable: false, enumerable: false, configurable: false, value:"undefined"});
descriptorShouldBe("global", "'NaN'", {writable: false, enumerable: false, configurable: false, value:"NaN"});
descriptorShouldBe("global", "'Infinity'", {writable: false, enumerable: false, configurable: false, value:"Infinity"});
descriptorShouldBe("global", "'window'", {writable: false, enumerable: true, configurable: false, value:"global"});
var globalWindowGetter = Object.getOwnPropertyDescriptor(global, 'window').get;
descriptorShouldBe("global", "'window'", {get: 'globalWindowGetter', set: undefined, enumerable: true, configurable: false});
descriptorShouldBe("global", "'XMLHttpRequest'", {writable: true, enumerable: false, configurable: true, value:"XMLHttpRequest"});
descriptorShouldBe("global", "0", {writable: true, enumerable: false, configurable: false, value:"global[0]"});
descriptorShouldBe("document.getElementsByTagName('div')", "0", {writable: false, enumerable: true, configurable: false, value:"document.getElementsByTagName('div')[0]"});
@@ -1,3 +1,22 @@
2016-06-03 Gavin & Ellie Barraclough <barraclough@apple.com>

Deprecate remaining uses of Lookup getStatic*, use HasStaticPropertyTable instead.
https://bugs.webkit.org/show_bug.cgi?id=158178

Reviewed by Darin Adler.

As of bug #158059 most JSC static table property access no longer requires getOwnPropertySlot to be
overridden. Port remaining calls to the getStatic* functions in Lookup.h over to the new mechanism.

Part 1: Switch JSGlobalObject & JSDOMWindow to use HasStaticPropertyTable.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::getOwnPropertySlot):
- Override is still required for symbol table,
but regular property access is now via Base::getOwnPropertySlot.
* runtime/JSGlobalObject.h:
- add HasStaticPropertyTable to structureFlags.

2016-06-03 Benjamin Poulain <bpoulain@apple.com>

Eager FTL failure for strict comparison of NaN with number check
@@ -1178,10 +1178,9 @@ void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)

bool JSGlobalObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
if (getStaticPropertySlot<JSGlobalObject, Base>(exec, globalObjectTable, thisObject, propertyName, slot))
if (Base::getOwnPropertySlot(object, exec, propertyName, slot))
return true;
return symbolTableGet(thisObject, propertyName, slot);
return symbolTableGet(jsCast<JSGlobalObject*>(object), propertyName, slot);
}

void JSGlobalObject::clearRareData(JSCell* cell)
@@ -387,7 +387,7 @@ class JSGlobalObject : public JSSegmentedVariableObject {

public:
typedef JSSegmentedVariableObject Base;
static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | OverridesToThis;
static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | OverridesToThis;

static JSGlobalObject* create(VM& vm, Structure* structure)
{
@@ -1,3 +1,36 @@
2016-06-03 Gavin & Ellie Barraclough <barraclough@apple.com>

Deprecate remaining uses of Lookup getStatic*, use HasStaticPropertyTable instead.
https://bugs.webkit.org/show_bug.cgi?id=158178

Reviewed by Darin Adler.

As of bug #158059 most JSC static table property access no longer requires getOwnPropertySlot to be
overridden. Port remaining calls to the getStatic* functions in Lookup.h over to the new mechanism.

Part 1: Switch JSGlobalObject & JSDOMWindow to use HasStaticPropertyTable.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::getOwnPropertySlot):
- getStaticPropertySlot -> Base::getOwnPropertySlot.
* bindings/js/JSPluginElementFunctions.h:
(WebCore::pluginElementCustomGetOwnPropertySlot):
- Switch call from getStaticValueSlot to Type::getOwnPropertySlot.
For any element where Type::hasStaticPropertyTable is true the HasStaticPropertyTable
structure flag will also be set, so Type::getOwnPropertySlot will do the same thing.
* bindings/scripts/CodeGeneratorJS.pm:
(PrototypeHasStaticPropertyTable):
- Was PrototypeOverridesGetOwnPropertySlot; prototypes now never need override getOwnPropertySlot so renaming accordingly.
(GenerateImplementation):
- Removed generation of getOwnPropertySlot body for DOMGlobalObjects.
(GeneratePrototypeDeclaration):
- For DOMGlobalObjects, set HasStaticPropertyTable instead of OverridesGetOwnPropertySlot & removed getOwnPropertySlot declaration.
(PrototypeOverridesGetOwnPropertySlot): Deleted.
Renamed to PrototypeHasStaticPropertyTable.
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
* bindings/scripts/test/JS/JSTestGlobalObject.h:
- Updating bindings test results.

2016-06-05 Antti Koivisto <antti@apple.com>

Find on page finds too many matches
@@ -236,7 +236,7 @@ bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, Property

// (2) Regular own properties.
PropertySlot slotCopy = slot;
if (getStaticPropertySlot<JSDOMWindow, Base>(exec, *JSDOMWindow::info()->staticPropHashTable, thisObject, propertyName, slot)) {
if (Base::getOwnPropertySlot(thisObject, exec, propertyName, slot)) {
// Detect when we're getting the property 'showModalDialog', this is disabled, and has its original value.
bool isShowModalDialogAndShouldHide = propertyName == exec->propertyNames().showModalDialog
&& !DOMWindow::canShowModalDialog(frame)

0 comments on commit f86e8a3

Please sign in to comment.