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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/js/toString-dontEnum.html

Issue 1905553002: Expose toString() as enumerable on some objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sof-tidy-idl-pars
Patch Set: rebased Created 4 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 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" charset="utf-8"> 3 <script type="text/javascript" charset="utf-8">
4 function log(msg) 4 function log(msg)
5 { 5 {
6 document.getElementById('console').appendChild(document.createTextNo de(msg + '\n')); 6 document.getElementById('console').appendChild(document.createTextNo de(msg + '\n'));
7 } 7 }
8 8
9 function test(element, name) 9 function test(element, name)
10 { 10 {
11 var didPass = true; 11 var didPass = true;
12 for (prop in element) { 12 for (prop in element) {
13 if (prop == "toString") 13 if (prop == "toString")
14 didPass = false; 14 didPass = false;
15 } 15 }
16 if (didPass) 16 if (didPass)
17 log("PASS: the toString function is not enumerable for " + name + "."); 17 log("PASS: the toString function is not enumerable for " + name + ".");
18 else 18 else
19 log("FAIL: the toString function is enumerable for " + name + " and should not be."); 19 log("FAIL: the toString function is enumerable for " + name + " and should not be.");
20 } 20 }
21 21
22 function runTests() 22 function runTests()
23 { 23 {
24 if (window.testRunner) 24 if (window.testRunner)
25 testRunner.dumpAsText(); 25 testRunner.dumpAsText();
26 26
27 // DOM objects with custom toString() functions 27 // DOM objects with custom toString() functions
28 test(document.createElement('a'), "HTMLAnchorElement");
29 test(window.location, "Location"); 28 test(window.location, "Location");
30 test(window.getSelection(), "Selection"); 29 test(window.getSelection(), "Selection");
31 30
32 // Other DOM objects 31 // Other DOM objects
33 test(document.createElement('div'), "HTMLDivElement"); 32 test(document.createElement('div'), "HTMLDivElement");
34 test(document, "HTMLDocument"); 33 test(document, "HTMLDocument");
35 34
36 // JS objects 35 // JS objects
37 test({}, "Object"); 36 test({}, "Object");
38 test([], "Array"); 37 test([], "Array");
39 } 38 }
40 </script> 39 </script>
41 </head> 40 </head>
42 <body onload="runTests();"> 41 <body onload="runTests();">
43 <p>This tests that the toString() function does not enumerate.</p> 42 <p>This tests that the toString() function does not enumerate.</p>
44 <pre id="console"></pre> 43 <pre id="console"></pre>
45 </body> 44 </body>
46 </html> 45 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698