Changeset 205535 in webkit
- Timestamp:
- Sep 6, 2016 7:48:35 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r205520 r205535 1 2016-09-06 Saam Barati <sbarati@apple.com> 2 3 ProxyObject's structure should not have ObjectPrototype as its prototype and it should not have special behavior for intercepting "__proto__" 4 https://bugs.webkit.org/show_bug.cgi?id=161558 5 6 Reviewed by Benjamin Poulain. 7 8 * stress/proxy-get-prototype-of.js: 9 * stress/proxy-set-prototype-of.js: 10 (let.handler.setPrototypeOf): Deleted. 11 * stress/proxy-underscore-proto.js: Added. 12 (assert): 13 1 14 2016-09-06 Saam Barati <sbarati@apple.com> 2 15 -
trunk/JSTests/stress/proxy-get-prototype-of.js
r198813 r205535 19 19 () => Reflect.getPrototypeOf(proxy), 20 20 () => Object.getPrototypeOf(proxy), 21 () => proxy.__proto__,22 21 ]; 23 22 for (let get of getters) { … … 49 48 () => Reflect.getPrototypeOf(proxy), 50 49 () => Object.getPrototypeOf(proxy), 51 () => proxy.__proto__,52 50 ]; 53 51 for (let get of getters) { … … 84 82 () => Reflect.getPrototypeOf(proxy), 85 83 () => Object.getPrototypeOf(proxy), 86 () => proxy.__proto__,87 84 ]; 88 85 for (let get of getters) { … … 110 107 () => Reflect.getPrototypeOf(proxy), 111 108 () => Object.getPrototypeOf(proxy), 112 () => proxy.__proto__,113 109 ]; 114 110 for (let get of getters) { … … 138 134 () => Reflect.getPrototypeOf(proxy), 139 135 () => Object.getPrototypeOf(proxy), 140 () => proxy.__proto__,141 136 ]; 142 137 for (let get of getters) { … … 166 161 () => Reflect.getPrototypeOf(proxy), 167 162 () => Object.getPrototypeOf(proxy), 168 () => proxy.__proto__,169 163 ]; 170 164 for (let get of getters) { … … 195 189 () => Reflect.getPrototypeOf(proxy), 196 190 () => Object.getPrototypeOf(proxy), 197 () => proxy.__proto__,198 191 ]; 199 192 for (let get of getters) { … … 225 218 () => Reflect.getPrototypeOf(proxy), 226 219 () => Object.getPrototypeOf(proxy), 227 () => proxy.__proto__,228 220 ]; 229 221 for (let get of getters) { … … 256 248 () => Reflect.getPrototypeOf(proxy), 257 249 () => Object.getPrototypeOf(proxy), 258 () => proxy.__proto__,259 250 ]; 260 251 for (let get of getters) { … … 286 277 () => Reflect.getPrototypeOf(proxy), 287 278 () => Object.getPrototypeOf(proxy), 288 () => proxy.__proto__,289 279 ]; 290 280 for (let get of getters) { … … 309 299 () => Reflect.getPrototypeOf(proxy), 310 300 () => Object.getPrototypeOf(proxy), 311 () => proxy.__proto__,312 301 ]; 313 302 for (let get of getters) { … … 334 323 () => Reflect.getPrototypeOf(proxy), 335 324 () => Object.getPrototypeOf(proxy), 336 () => proxy.__proto__,337 325 ]; 338 326 for (let get of getters) { … … 361 349 () => Reflect.getPrototypeOf(proxy), 362 350 () => Object.getPrototypeOf(proxy), 363 () => proxy.__proto__,364 351 ]; 365 352 for (let get of getters) { … … 388 375 () => Reflect.getPrototypeOf(proxy), 389 376 () => Object.getPrototypeOf(proxy), 390 () => proxy.__proto__,391 377 ]; 392 378 for (let get of getters) { -
trunk/JSTests/stress/proxy-set-prototype-of.js
r198813 r205535 19 19 () => Reflect.setPrototypeOf(proxy, {}), 20 20 () => Object.setPrototypeOf(proxy, {}), 21 () => proxy.__proto__ = {},22 21 ]; 23 22 for (let set of setters) { … … 49 48 () => Reflect.setPrototypeOf(proxy, {}), 50 49 () => Object.setPrototypeOf(proxy, {}), 51 () => proxy.__proto__ = {},52 50 ]; 53 51 for (let set of setters) { … … 76 74 () => Reflect.setPrototypeOf(proxy, {}), 77 75 () => Object.setPrototypeOf(proxy, {}), 78 () => proxy.__proto__ = {},79 76 ]; 80 77 for (let set of setters) { … … 105 102 () => Reflect.setPrototypeOf(proxy, {}), 106 103 () => Object.setPrototypeOf(proxy, {}), 107 () => proxy.__proto__ = {},108 104 ]; 109 105 for (let set of setters) { … … 111 107 assert(result); 112 108 assert(Reflect.getPrototypeOf(target) === null); 113 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 114 //assert(Reflect.getPrototypeOf(proxy) === null); 115 //assert(proxy.__proto__ === null); 109 assert(Reflect.getPrototypeOf(proxy) === null); 110 assert(proxy.__proto__ === undefined); 116 111 } 117 112 } … … 134 129 () => Reflect.setPrototypeOf(proxy, obj), 135 130 () => Object.setPrototypeOf(proxy, obj), 136 () => proxy.__proto__ = obj,137 131 ]; 138 132 for (let set of setters) { … … 140 134 assert(result); 141 135 assert(Reflect.getPrototypeOf(target) === obj); 142 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 143 //assert(Reflect.getPrototypeOf(proxy) === obj); 144 //assert(proxy.__proto__ === obj); 136 assert(Reflect.getPrototypeOf(proxy) === obj); 137 assert(proxy.__proto__ === obj); 145 138 } 146 139 } … … 168 161 () => Reflect.setPrototypeOf(proxy, obj), 169 162 () => Object.setPrototypeOf(proxy, obj), 170 () => proxy.__proto__ = obj,171 163 ]; 172 164 for (let set of setters) { … … 183 175 assert(threw); 184 176 assert(Reflect.getPrototypeOf(target) === null); 185 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 186 //assert(Reflect.getPrototypeOf(proxy) === null); 187 //assert(proxy.__proto__ === null); 177 assert(Reflect.getPrototypeOf(proxy) === null); 178 assert(proxy.__proto__ === undefined); 188 179 } 189 180 } … … 210 201 [() => Reflect.setPrototypeOf(proxy, null), true], 211 202 [() => Object.setPrototypeOf(proxy, null), proxy], 212 [() => proxy.__proto__ = null, null]213 203 ]; 214 204 for (let [set, expectedResult] of setters) { … … 218 208 called = false; 219 209 assert(Reflect.getPrototypeOf(target) === null); 220 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 221 //assert(Reflect.getPrototypeOf(proxy) === null); 222 //assert(proxy.__proto__ === null); 210 assert(Reflect.getPrototypeOf(proxy) === null); 211 assert(proxy.__proto__ === undefined); 223 212 } 224 213 } … … 246 235 [() => Reflect.setPrototypeOf(proxy, obj), true], 247 236 [() => Object.setPrototypeOf(proxy, obj), proxy], 248 [() => proxy.__proto__ = obj, obj]249 237 ]; 250 238 for (let [set, expectedResult] of setters) { … … 254 242 called = false; 255 243 assert(Reflect.getPrototypeOf(target) === obj); 256 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 257 //assert(Reflect.getPrototypeOf(proxy) === null); 258 //assert(proxy.__proto__ === null); 244 assert(Reflect.getPrototypeOf(proxy) === obj); 245 assert(proxy.__proto__ === obj); 259 246 } 260 247 } … … 284 271 assert(threw); 285 272 assert(Reflect.getPrototypeOf(target) === null); 286 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 287 //assert(Reflect.getPrototypeOf(proxy) === null); 288 //assert(proxy.__proto__ === null); 289 } 290 } 291 292 { 293 let target = {}; 294 target.__proto__ = null; 295 Reflect.preventExtensions(target); 296 let handler = { 297 setPrototypeOf: function(theTarget, value) { 298 return Reflect.setPrototypeOf(theTarget, value); 299 } 300 }; 301 302 let proxy = new Proxy(target, handler); 303 for (let i = 0; i < 500; i++) { 304 let obj = {}; 305 let threw = false; 306 try { 307 proxy.__proto__ = obj; 308 } catch(e) { 309 threw = true; 310 assert(e.toString() === "TypeError: Proxy 'setPrototypeOf' returned false indicating it could not set the prototype value. The operation was expected to succeed"); 311 } 312 313 assert(threw); 314 assert(Reflect.getPrototypeOf(target) === null); 315 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 316 //assert(Reflect.getPrototypeOf(proxy) === null); 317 //assert(proxy.__proto__ === null); 273 assert(Reflect.getPrototypeOf(proxy) === null); 274 assert(proxy.__proto__ === undefined); 318 275 } 319 276 } … … 340 297 assert(called); 341 298 called = false; 342 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 343 //assert(Reflect.getPrototypeOf(proxy) === null); 344 //assert(proxy.__proto__ === null); 299 assert(Reflect.getPrototypeOf(proxy) === null); 300 assert(proxy.__proto__ === undefined); 345 301 } 346 302 } … … 367 323 called = false; 368 324 369 // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work. 370 //assert(Reflect.getPrototypeOf(proxy) === null); 371 //assert(proxy.__proto__ === null); 325 assert(Reflect.getPrototypeOf(proxy) === null); 326 assert(proxy.__proto__ === undefined); 372 327 } 373 328 } -
trunk/Source/JavaScriptCore/ChangeLog
r205534 r205535 1 2016-09-06 Saam Barati <sbarati@apple.com> 2 3 ProxyObject's structure should not have ObjectPrototype as its prototype and it should not have special behavior for intercepting "__proto__" 4 https://bugs.webkit.org/show_bug.cgi?id=161558 5 6 Reviewed by Benjamin Poulain. 7 8 ProxyObject had ObjectPrototype as its direct prototype. 9 This could lead to infinite loops when doing a getDirectPrototype() 10 loop. 11 12 Fixing this bug revealed another bug, which I made when implementing Proxy. 13 We should not special case "__proto__" in get and set for Proxy Object's 14 hooks. "__proto__" should just go through the normal set and get path. 15 16 * runtime/JSGlobalObject.cpp: 17 (JSC::JSGlobalObject::init): 18 * runtime/ProxyObject.cpp: 19 (JSC::performProxyGet): 20 (JSC::ProxyObject::put): 21 1 22 2016-09-06 Yusuke Suzuki <utatane.tea@gmail.com> 2 23 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r205520 r205535 509 509 { 510 510 bool isCallable = false; 511 m_proxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, m_objectPrototype.get(), isCallable));511 m_proxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable)); 512 512 isCallable = true; 513 m_callableProxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, m_objectPrototype.get(), isCallable));513 m_callableProxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable)); 514 514 } 515 515 m_proxyRevokeStructure.set(vm, this, ProxyRevoke::createStructure(vm, this, m_functionPrototype.get())); -
trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp
r205462 r205535 126 126 JSObject* target = proxyObject->target(); 127 127 128 if (propertyName == vm.propertyNames->underscoreProto)129 return proxyObject->performGetPrototype(exec);130 131 128 auto performDefaultGet = [&] { 132 129 return target->get(exec, propertyName); … … 459 456 VM& vm = exec->vm(); 460 457 slot.disableCaching(); 461 if (propertyName == vm.propertyNames->underscoreProto)462 return Base::put(cell, exec, propertyName, value, slot);463 458 464 459 ProxyObject* thisObject = jsCast<ProxyObject*>(cell);
Note: See TracChangeset
for help on using the changeset viewer.