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

Side by Side Diff: LayoutTests/fast/dom/script-tests/constructed-objects-prototypes.js

Issue 14447006: Global constructors should be configurable and not enumerable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean rebase on master Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description("Make sure prototypes are set up using the window a property came fr om, instead of the lexical global object.") 1 description("Make sure prototypes are set up using the window a property came fr om, instead of the lexical global object.")
2 2
3 var subframe = document.createElement("iframe"); 3 var subframe = document.createElement("iframe");
4 document.body.appendChild(subframe); 4 document.body.appendChild(subframe);
5 var inner = subframe.contentWindow; // Call it "inner" to make shouldBe output s horter 5 var inner = subframe.contentWindow; // Call it "inner" to make shouldBe output s horter
6 6
7 // Stash a property on the prototypes. 7 // Stash a property on the prototypes.
8 window.Object.prototype.isInner = false; 8 window.Object.prototype.isInner = false;
9 inner.Object.prototype.isInner = true; 9 inner.Object.prototype.isInner = true;
10 10
11 function classNameForObject(object) 11 function classNameForObject(object)
12 { 12 {
13 // call will use the global object if passed null or undefined, so special c ase those: 13 // call will use the global object if passed null or undefined, so special c ase those:
14 if (object == null) 14 if (object == null)
15 return null; 15 return null;
16 var result = Object.prototype.toString.call(object); 16 var result = Object.prototype.toString.call(object);
17 // remove '[object ' and ']' 17 // remove '[object ' and ']'
18 return result.split(' ')[1].split(']')[0]; 18 return result.split(' ')[1].split(']')[0];
19 } 19 }
20 20
21 function constructorPropertiesOnWindow(globalObject) 21 function constructorPropertiesOnWindow(globalObject)
22 { 22 {
23 var constructorNames = []; 23 var constructorNames = [];
24 for (var property in globalObject) { 24 var propertyNames = Object.getOwnPropertyNames(window);
25 var value = inner[property]; 25 for (var i = 0; i < propertyNames.length; i++) {
26 var value = inner[propertyNames[i]];
26 if (value == null) 27 if (value == null)
27 continue; 28 continue;
28 var type = classNameForObject(value); 29 var type = classNameForObject(value);
29 // Ignore these properties because they do not exist in all implementati ons. They will be tested separately 30 // Ignore these properties because they do not exist in all implementati ons. They will be tested separately
30 if (type == "WebGLRenderingContextConstructor" || 31 if (type == "WebGLRenderingContextConstructor" ||
31 type == "ArrayBufferConstructor" || 32 type == "ArrayBufferConstructor" ||
32 type =="Float32ArrayConstructor" || 33 type =="Float32ArrayConstructor" ||
33 type =="Float64ArrayConstructor" || 34 type =="Float64ArrayConstructor" ||
34 type =="Int8ArrayConstructor" || 35 type =="Int8ArrayConstructor" ||
35 type =="Int16ArrayConstructor" || 36 type =="Int16ArrayConstructor" ||
(...skipping 30 matching lines...) Expand all
66 constructedObject = eval("new inner." + constructorName + argumentsStrin g); 67 constructedObject = eval("new inner." + constructorName + argumentsStrin g);
67 } catch(e) { 68 } catch(e) {
68 continue; 69 continue;
69 } 70 }
70 71
71 shouldBeTrue("(new inner." + constructorName + argumentsString + ").isInner" ); 72 shouldBeTrue("(new inner." + constructorName + argumentsString + ").isInner" );
72 shouldBeTrue("(new inner." + constructorName + argumentsString + ").construc tor.isInner"); 73 shouldBeTrue("(new inner." + constructorName + argumentsString + ").construc tor.isInner");
73 } 74 }
74 75
75 document.body.removeChild(subframe); 76 document.body.removeChild(subframe);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698