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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-command-line-api-can-be-overriden.html

Issue 2954093003: [DevTools] Migrate inspector-protocol/runtime tests to new harness (Closed)
Patch Set: fail: Created 3 years, 5 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
(Empty)
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource s/inspector-protocol-test.js"></script>
4 <script>
5
6 function overrideDir()
7 {
8 var v = "" + dir;
9 dir = 239;
10 return v + " -> " + dir;
11 }
12
13 function override$_()
14 {
15 var v = "" + $_;
16 $_ = 239;
17 return v + " -> " + $_;
18 }
19
20 function doesCommandLineAPIEnumerable()
21 {
22 for (var v in window) {
23 if (v === "dir" || v === "$_")
24 return "enumerable";
25 }
26 return "non enumerable";
27 }
28
29 function test()
30 {
31 function evaluatePromise(expression)
32 {
33 var cb;
34 var p = new Promise(resolver => cb = resolver);
35 InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": expre ssion, objectGroup: "console", includeCommandLineAPI: true }, cb);
36 return p;
37 }
38
39 evaluatePromise("doesCommandLineAPIEnumerable()")
40 .then(dumpResult.bind(null, "Check that CommandLineAPI isn't enumerable on window object:"))
41 .then(() => evaluatePromise("overrideDir()"))
42 .then(dumpResult.bind(null, "Override dir:"))
43 .then(() => evaluatePromise("\"\" + dir"))
44 .then(dumpResult.bind(null, "CommandLineAPI doesn't override dir:"))
45 .then(() => evaluatePromise("delete dir"))
46 .then(() => evaluatePromise("overrideDir()"))
47 .then(dumpResult.bind(null, "CommandLineAPI is presented after removing override variable:"))
48 // set $_ to 42
49 .then(() => evaluatePromise("42"))
50 .then(() => evaluatePromise("override$_()"))
51 .then(dumpResult.bind(null, "Override $_:"))
52 .then(() => evaluatePromise("\"\" + $_"))
53 .then(dumpResult.bind(null, "CommandLineAPI doesn't override $_:"))
54 .then(() => evaluatePromise("delete $_"))
55 .then(() => evaluatePromise("override$_()"))
56 .then(dumpResult.bind(null, "CommandLineAPI is presented after removing override variable:"))
57 .then(() => evaluatePromise("var dir = 1; \"\" + dir"))
58 .then(dumpResult.bind(null, "CommandLineAPI can be overridden by var dir = 1:"))
59 .then(() => evaluatePromise("\"\" + dir"))
60 .then(dumpResult.bind(null, "CommandLineAPI doesn't override var dir = 1 :"))
61 .then(() => evaluatePromise("Object.defineProperty(window, \"copy\", { g et: () => 239 }); \"\" + copy"))
62 .then(dumpResult.bind(null, "CommandLineAPI can be overridden by Object. defineProperty:"))
63 .then(() => evaluatePromise("\"\" + copy"))
64 .then(dumpResult.bind(null, "CommandLineAPI doesn't override Object.defi neProperty:"))
65 .then(() => InspectorTest.completeTest());
66
67 function dumpResult(title, message)
68 {
69 InspectorTest.log(title);
70 InspectorTest.log(message.result.value);
71 }
72 }
73 </script>
74 </head>
75 <body onLoad="runTest();">
76 Tests that Command Line API doesn't override defined on window methods and can b e overridden during evaluation.
77 </body>
78 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698