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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-clear-of-command-line-api.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 var methods = ["dir","dirxml","profile","profileEnd","clear","table","keys","val ues","debug","undebug","monitor","unmonitor","inspect","copy"];
7
8 function presentedAPIMethods()
9 {
10 var methodCount = 0;
11 for (var method of methods) {
12 try {
13 if (eval("window." + method + "&&" + method + ".toString ? " + metho d + ".toString().indexOf(\"[Command Line API]\") !== -1 : false"))
14 ++methodCount;
15 } catch (e) {
16 }
17 }
18 methodCount += eval("\"$_\" in window ? $_ === 239 : false") ? 1 : 0;
19 return methodCount;
20 }
21
22 function setPropertyForMethod()
23 {
24 window.dir = 42;
25 }
26
27 function defineValuePropertyForMethod()
28 {
29 Object.defineProperty(window, "dir", { value: 42 });
30 }
31
32 function defineAccessorPropertyForMethod()
33 {
34 Object.defineProperty(window, "dir", { set: function() {}, get: function(){ return 42 } });
35 }
36
37 function definePropertiesForMethod()
38 {
39 Object.defineProperties(window, { "dir": { set: function() {}, get: function (){ return 42 } }});
40 }
41
42 var builtinGetOwnPropertyDescriptorOnObject;
43 var builtinGetOwnPropertyDescriptorOnObjectPrototype;
44 var builtinGetOwnPropertyDescriptorOnWindow;
45
46 function redefineGetOwnPropertyDescriptors()
47 {
48 builtinGetOwnPropertyDescriptorOnObject = Object.getOwnPropertyDescriptor;
49 Object.getOwnPropertyDescriptor = function() {}
50 builtinGetOwnPropertyDescriptorOnObjectPrototype = Object.prototype.getOwnPr opertyDescriptor;
51 Object.prototype.getOwnPropertyDescriptor = function() {}
52 builtinGetOwnPropertyDescriptorOnWindow = window.getOwnPropertyDescriptor;
53 window.getOwnPropertyDescriptor = function() {}
54 }
55
56 function restoreGetOwnPropertyDescriptors()
57 {
58 Object.getOwnPropertyDescriptor = builtinGetOwnPropertyDescriptorOnObject;
59 Object.prototype.getOwnPropertyDescriptor = builtinGetOwnPropertyDescriptorO nObjectPrototype;
60 window.getOwnPropertyDescriptor = builtinGetOwnPropertyDescriptorOnWindow;
61 }
62
63
64 function test()
65 {
66 runExpressionAndDumpPresentedMethods("")
67 .then(() => dumpLeftMethods())
68 .then(() => runExpressionAndDumpPresentedMethods("setPropertyForMethod() "))
69 .then(() => dumpLeftMethods())
70 .then(() => dumpDir())
71 .then(() => runExpressionAndDumpPresentedMethods("defineValuePropertyFor Method()"))
72 .then(() => dumpLeftMethods())
73 .then(() => dumpDir())
74 .then(() => runExpressionAndDumpPresentedMethods("definePropertiesForMet hod()"))
75 .then(() => dumpLeftMethods())
76 .then(() => dumpDir())
77 .then(() => runExpressionAndDumpPresentedMethods("defineAccessorProperty ForMethod()"))
78 .then(() => dumpLeftMethods())
79 .then(() => dumpDir())
80 .then(() => runExpressionAndDumpPresentedMethods("redefineGetOwnProperty Descriptors()"))
81 .then(() => dumpLeftMethods())
82 .then(() => dumpDir())
83 .then(() => evaluate("restoreGetOwnPropertyDescriptors()", false))
84 .then(() => InspectorTest.completeTest());
85
86 function evaluate(expression, includeCommandLineAPI)
87 {
88 var cb;
89 var p = new Promise(resolver => cb = resolver);
90 InspectorTest.sendCommandOrDie("Runtime.evaluate", { expression: express ion, objectGroup: "console", includeCommandLineAPI: includeCommandLineAPI }, cb) ;
91 return p;
92 }
93
94 function setLastEvaluationResultTo239()
95 {
96 return evaluate("239", false);
97 }
98
99 function runExpressionAndDumpPresentedMethods(expression)
100 {
101 InspectorTest.log(expression);
102 return setLastEvaluationResultTo239()
103 .then(() => evaluate(expression + "; var a = presentedAPIMethods(); a", true))
104 .then((result) => InspectorTest.logObject(result));
105 }
106
107 function dumpLeftMethods()
108 {
109 // Should always be zero.
110 return setLastEvaluationResultTo239()
111 .then(() => evaluate("presentedAPIMethods()", false))
112 .then((result) => InspectorTest.logObject(result));
113 }
114
115 function dumpDir()
116 {
117 // Should always be presented.
118 return evaluate("dir", false)
119 .then((result) => InspectorTest.logObject(result));
120 }
121 }
122 </script>
123 </head>
124 <body onLoad="runTest();">
125 Tests that CommandLineAPI is presented only while evaluation.
126 </body>
127 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698