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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-clear-of-command-line-api.js

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 (async function(testRunner) {
2 let {page, session, dp} = await testRunner.startBlank('Tests that CommandLineA PI is presented only while evaluation.');
3
4 await session.evaluate(`
5 var methods = ['dir','dirxml','profile','profileEnd','clear','table','keys', 'values','debug','undebug','monitor','unmonitor','inspect','copy'];
6
7 function presentedAPIMethods() {
8 var methodCount = 0;
9 for (var method of methods) {
10 try {
11 if (eval('window.' + method + '&&' + method + '.toString ? ' + method + '.toString().indexOf("[Command Line API]") !== -1 : false'))
12 ++methodCount;
13 } catch (e) {
14 }
15 }
16 methodCount += eval('"$_" in window ? $_ === 239 : false') ? 1 : 0;
17 return methodCount;
18 }
19
20 function setPropertyForMethod() {
21 window.dir = 42;
22 }
23
24 function defineValuePropertyForMethod() {
25 Object.defineProperty(window, 'dir', { value: 42 });
26 }
27
28 function defineAccessorPropertyForMethod() {
29 Object.defineProperty(window, 'dir', { set: function() {}, get: function() { return 42 } });
30 }
31
32 function definePropertiesForMethod() {
33 Object.defineProperties(window, { 'dir': { set: function() {}, get: functi on(){ return 42 } }});
34 }
35
36 var builtinGetOwnPropertyDescriptorOnObject;
37 var builtinGetOwnPropertyDescriptorOnObjectPrototype;
38 var builtinGetOwnPropertyDescriptorOnWindow;
39
40 function redefineGetOwnPropertyDescriptors() {
41 builtinGetOwnPropertyDescriptorOnObject = Object.getOwnPropertyDescriptor;
42 Object.getOwnPropertyDescriptor = function() {};
43 builtinGetOwnPropertyDescriptorOnObjectPrototype = Object.prototype.getOwn PropertyDescriptor;
44 Object.prototype.getOwnPropertyDescriptor = function() {};
45 builtinGetOwnPropertyDescriptorOnWindow = window.getOwnPropertyDescriptor;
46 window.getOwnPropertyDescriptor = function() {};
47 }
48
49 function restoreGetOwnPropertyDescriptors() {
50 Object.getOwnPropertyDescriptor = builtinGetOwnPropertyDescriptorOnObject;
51 Object.prototype.getOwnPropertyDescriptor = builtinGetOwnPropertyDescripto rOnObjectPrototype;
52 window.getOwnPropertyDescriptor = builtinGetOwnPropertyDescriptorOnWindow;
53 }
54 `);
55
56 async function evaluate(expression, includeCommandLineAPI) {
57 var response = await dp.Runtime.evaluate({ expression: expression, objectGro up: 'console', includeCommandLineAPI: includeCommandLineAPI });
58 return response.result;
59 }
60
61 function setLastEvaluationResultTo239() {
62 return evaluate('239', false);
63 }
64
65 async function runExpressionAndDumpPresentedMethods(expression) {
66 testRunner.log(expression);
67 await setLastEvaluationResultTo239();
68 var result = await evaluate(expression + '; var a = presentedAPIMethods(); a ', true);
69 testRunner.logObject(result);
70 }
71
72 async function dumpLeftMethods() {
73 // Should always be zero.
74 await setLastEvaluationResultTo239();
75 var result = await evaluate('presentedAPIMethods()', false);
76 testRunner.logObject(result);
77 }
78
79 async function dumpDir() {
80 // Should always be presented.
81 var result = await evaluate('dir', false);
82 testRunner.logObject(result);
83 }
84
85 await runExpressionAndDumpPresentedMethods('');
86 await dumpLeftMethods();
87 await runExpressionAndDumpPresentedMethods('setPropertyForMethod()');
88 await dumpLeftMethods();
89 await dumpDir();
90 await runExpressionAndDumpPresentedMethods('defineValuePropertyForMethod()');
91 await dumpLeftMethods();
92 await dumpDir();
93 await runExpressionAndDumpPresentedMethods('definePropertiesForMethod()');
94 await dumpLeftMethods();
95 await dumpDir();
96 await runExpressionAndDumpPresentedMethods('defineAccessorPropertyForMethod()' );
97 await dumpLeftMethods();
98 await dumpDir();
99 await runExpressionAndDumpPresentedMethods('redefineGetOwnPropertyDescriptors( )');
100 await dumpLeftMethods();
101 await dumpDir();
102 await evaluate('restoreGetOwnPropertyDescriptors()', false);
103 testRunner.completeTest();
104 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698