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

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

Issue 2030453002: [DevTools] Support CommandLineAPI in workers and Node.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/inspecto r-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(() => InspectorTest.completeTest());
58
59 function dumpResult(title, message)
60 {
61 InspectorTest.log(title);
62 InspectorTest.log(message.result.value);
63 }
64 }
65 </script>
66 </head>
67 <body onLoad="runTest();">
68 Tests that Command Line API doesn't override defined on window methods and can b e overridden during evaluation.
69 </body>
70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698