Source/JavaScriptCore/ChangeLog

 12013-04-02 Mark Hahnenberg <mhahnenberg@apple.com>
 2
 3 get_by_pname can become confused when iterating over objects with static properties
 4 https://bugs.webkit.org/show_bug.cgi?id=113831
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 get_by_pname doesn't take static properties into account when using a JSPropertyNameIterator to directly
 9 access an object's backing store. One way to fix this is to not cache any properties when iterating over
 10 objects with static properties. This patch fixes the bug that was originally reported on swisscom.ch.
 11
 12 * runtime/JSObject.cpp:
 13 (JSC::JSObject::getOwnNonIndexPropertyNames):
 14 * runtime/JSPropertyNameIterator.cpp:
 15 (JSC::JSPropertyNameIterator::create):
 16 * runtime/PropertyNameArray.h:
 17 (JSC::PropertyNameArray::PropertyNameArray):
 18 (JSC::PropertyNameArray::numCacheableSlots):
 19 (JSC::PropertyNameArray::setNumCacheableSlots):
 20 (PropertyNameArray):
 21
1222013-04-02 Geoffrey Garen <ggaren@apple.com>
223
324 DFG should compile a little sooner
147565

Source/JavaScriptCore/runtime/JSObject.cpp

@@void JSObject::getOwnPropertyNames(JSObj
15321532void JSObject::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
15331533{
15341534 getClassPropertyNames(exec, object->classInfo(), propertyNames, mode, object->staticFunctionsReified());
 1535 size_t preStructurePropertyNamesCount = propertyNames.size();
15351536 object->structure()->getPropertyNamesFromStructure(exec->globalData(), propertyNames, mode);
 1537 size_t numCacheableSlots = preStructurePropertyNamesCount ? 0 : propertyNames.size();
 1538 propertyNames.setNumCacheableSlots(numCacheableSlots);
15361539}
15371540
15381541double JSObject::toNumber(ExecState* exec) const
147565

Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp

@@JSPropertyNameIterator* JSPropertyNameIt
5454 size_t numCacheableSlots = 0;
5555 if (!o->structure()->hasNonEnumerableProperties() && !o->structure()->hasGetterSetterProperties()
5656 && !o->structure()->isUncacheableDictionary() && !o->structure()->typeInfo().overridesGetPropertyNames())
57  numCacheableSlots = o->structure()->totalStorageSize();
 57 numCacheableSlots = propertyNames.numCacheableSlots();
5858
5959 JSPropertyNameIterator* jsPropertyNameIterator = new (NotNull, allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
6060 jsPropertyNameIterator->finishCreation(exec, propertyNames.data(), o);
147565

Source/JavaScriptCore/runtime/PropertyNameArray.h

@@namespace JSC {
5555 PropertyNameArray(JSGlobalData* globalData)
5656 : m_data(PropertyNameArrayData::create())
5757 , m_globalData(globalData)
 58 , m_numCacheableSlots(0)
5859 {
5960 }
6061
6162 PropertyNameArray(ExecState* exec)
6263 : m_data(PropertyNameArrayData::create())
6364 , m_globalData(&exec->globalData())
 65 , m_numCacheableSlots(0)
6466 {
6567 }
6668

@@namespace JSC {
8385 const_iterator begin() const { return m_data->propertyNameVector().begin(); }
8486 const_iterator end() const { return m_data->propertyNameVector().end(); }
8587
 88 size_t numCacheableSlots() const { return m_numCacheableSlots; }
 89 void setNumCacheableSlots(size_t numCacheableSlots) { m_numCacheableSlots = numCacheableSlots; }
 90
8691 private:
8792 typedef HashSet<StringImpl*, PtrHash<StringImpl*> > IdentifierSet;
8893
8994 RefPtr<PropertyNameArrayData> m_data;
9095 IdentifierSet m_set;
9196 JSGlobalData* m_globalData;
 97 size_t m_numCacheableSlots;
9298 };
9399
94100} // namespace JSC
147565

LayoutTests/ChangeLog

 12013-04-02 Mark Hahnenberg <mhahnenberg@apple.com>
 2
 3 get_by_pname can become confused when iterating over objects with static properties
 4 https://bugs.webkit.org/show_bug.cgi?id=113831
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 get_by_pname doesn't take static properties into account when using a JSPropertyNameIterator to directly
 9 access an object's backing store. One way to fix this is to not cache any properties when iterating over
 10 objects with static properties. This patch fixes the bug that was originally reported on swisscom.ch.
 11
 12 * fast/js/dom-static-property-for-in-iteration-expected.txt: Added.
 13 * fast/js/dom-static-property-for-in-iteration.html: Added.
 14
1152013-04-03 Felipe Zimmerle <felipe@zimmerle.org>
216
317 CSP blocks inline style when cloning a node
147565

LayoutTests/fast/js/dom-static-property-for-in-iteration-expected.txt

 1Checks that get_by_pname doesn't get confused about which properties go where when it comes to stacic properties.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS true is true
 7PASS true is true
 8PASS true is true
 9PASS true is true
 10PASS true is true
 11PASS true is true
 12PASS true is true
 13PASS true is true
 14PASS true is true
 15PASS true is true
 16PASS true is true
 17PASS true is true
 18PASS true is true
 19PASS true is true
 20PASS true is true
 21PASS true is true
 22PASS true is true
 23PASS true is true
 24PASS true is true
 25PASS true is true
 26PASS true is true
 27PASS true is true
 28PASS true is true
 29PASS true is true
 30PASS true is true
 31PASS true is true
 32PASS true is true
 33PASS true is true
 34PASS true is true
 35PASS true is true
 36PASS true is true
 37PASS true is true
 38PASS true is true
 39PASS true is true
 40PASS true is true
 41PASS true is true
 42PASS true is true
 43PASS true is true
 44PASS true is true
 45PASS true is true
 46PASS true is true
 47PASS true is true
 48PASS true is true
 49PASS true is true
 50PASS true is true
 51PASS true is true
 52PASS true is true
 53PASS true is true
 54PASS true is true
 55PASS true is true
 56PASS true is true
 57PASS true is true
 58PASS true is true
 59PASS true is true
 60PASS true is true
 61PASS true is true
 62PASS true is true
 63PASS true is true
 64PASS true is true
 65PASS true is true
 66PASS true is true
 67PASS true is true
 68PASS true is true
 69PASS true is true
 70PASS true is true
 71PASS true is true
 72PASS true is true
 73PASS true is true
 74PASS true is true
 75PASS true is true
 76PASS true is true
 77PASS true is true
 78PASS true is true
 79PASS true is true
 80PASS true is true
 81PASS true is true
 82PASS true is true
 83PASS true is true
 84PASS true is true
 85PASS true is true
 86PASS true is true
 87PASS true is true
 88PASS true is true
 89PASS true is true
 90PASS true is true
 91PASS true is true
 92PASS true is true
 93PASS true is true
 94PASS true is true
 95PASS true is true
 96PASS true is true
 97PASS true is true
 98PASS true is true
 99PASS true is true
 100PASS true is true
 101PASS true is true
 102PASS true is true
 103PASS true is true
 104PASS true is true
 105PASS true is true
 106PASS true is true
 107PASS true is true
 108PASS true is true
 109PASS true is true
 110PASS true is true
 111PASS true is true
 112PASS true is true
 113PASS true is true
 114PASS true is true
 115PASS true is true
 116PASS true is true
 117PASS true is true
 118PASS true is true
 119PASS true is true
 120PASS true is true
 121PASS true is true
 122PASS true is true
 123PASS true is true
 124PASS true is true
 125PASS true is true
 126PASS true is true
 127PASS true is true
 128PASS true is true
 129PASS true is true
 130PASS true is true
 131PASS true is true
 132PASS true is true
 133PASS true is true
 134PASS true is true
 135PASS true is true
 136PASS true is true
 137PASS true is true
 138PASS true is true
 139PASS true is true
 140PASS true is true
 141PASS true is true
 142PASS true is true
 143PASS true is true
 144PASS true is true
 145PASS true is true
 146PASS true is true
 147PASS true is true
 148PASS true is true
 149PASS true is true
 150PASS true is true
 151PASS true is true
 152PASS true is true
 153PASS true is true
 154PASS true is true
 155PASS true is true
 156PASS true is true
 157PASS true is true
 158PASS true is true
 159PASS true is true
 160PASS true is true
 161PASS true is true
 162PASS true is true
 163PASS true is true
 164PASS successfullyParsed is true
 165
 166TEST COMPLETE
 167nerget
0

LayoutTests/fast/js/dom-static-property-for-in-iteration.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<title>Test</title>
 5<script src="resources/js-test-pre.js"></script>
 6</head>
 7<body>
 8 <a id="foo" href="bar">nerget</a>
 9 <script>
 10 description(
 11 "Checks that get_by_pname doesn't get confused about which properties go where when it comes to stacic properties."
 12 );
 13
 14 function f(a) {
 15 for (var i in a) {
 16 var actual = a[i];
 17 var expected = a["" + i];
 18 shouldBeTrue(String(actual === expected));
 19 }
 20 }
 21 var g = document.getElementById("foo");
 22 g.foo="1";
 23 g.bar="2";
 24 g.wibble="3";
 25 g.hick="4";
 26 g.hock="5";
 27 g.snood="6";
 28 f(g);
 29 </script>
 30 <script src="resources/js-test-post.js"></script>
 31</body>
 32</html>
0