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

Side by Side Diff: LayoutTests/http/tests/inspector/inspector-test.js

Issue 1044203004: [Storage] Cache storage inspection on all the frames! (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 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 var initialize_InspectorTest = function() { 1 var initialize_InspectorTest = function() {
2 2
3 var results = []; 3 var results = [];
4 4
5 function consoleOutputHook(messageType) 5 function consoleOutputHook(messageType)
6 { 6 {
7 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu ments, 1)); 7 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu ments, 1));
8 } 8 }
9 9
10 window._originalConsoleLog = console.log.bind(console); 10 window._originalConsoleLog = console.log.bind(console);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 InspectorTest.evaluateInPageWithTimeout = function(code) 52 InspectorTest.evaluateInPageWithTimeout = function(code)
53 { 53 {
54 // FIXME: we need a better way of waiting for chromium events to happen 54 // FIXME: we need a better way of waiting for chromium events to happen
55 InspectorTest.evaluateInPage("setTimeout(unescape('" + escape(code) + "'), 1 )"); 55 InspectorTest.evaluateInPage("setTimeout(unescape('" + escape(code) + "'), 1 )");
56 } 56 }
57 57
58 var lastEvalId = 0; 58 var lastEvalId = 0;
59 var pendingEvalRequests = {}; 59 var pendingEvalRequests = {};
60 60
61 var lastPromiseEvalId = 0;
62 var pendingPromiseEvalRequests = {};
63
64 /**
65 * The given function should take two callback paraters before the arguments:
66 * * resolve - called when successful (with optional result)
67 * * reject - called when there was a failure (with optional error)
68 */
69 InspectorTest.invokePageFunctionPromise = function(functionName, parameters)
70 {
71 return new Promise(function(resolve, reject) {
72 var id = ++lastPromiseEvalId;
73 pendingPromiseEvalRequests[id] = { resolve: InspectorTest.safeWrap(resol ve), reject: InspectorTest.safeWrap(reject) };
74
75 var jsonParameters = [];
76 for (var i = 0; i < parameters.length; ++i)
77 jsonParameters.push(JSON.stringify(parameters[i]));
78 var asyncEvalWrapper = function(callId, functionName, argumentsArray)
79 {
80 function evalCallbackResolve(result)
81 {
82 testRunner.evaluateInWebInspector(evalCallbackCallId, "Inspector Test.didInvokePageFunctionPromise(" + callId + ", " + JSON.stringify(result) + " , true);");
83 }
84 function evalCallbackReject(result)
pfeldman 2015/04/15 17:50:08 Blank lines around functions.
dmurph 2015/04/15 21:29:32 Done.
85 {
86 testRunner.evaluateInWebInspector(evalCallbackCallId, "Inspector Test.didInvokePageFunctionPromise(" + callId + ", " + JSON.stringify(result) + " , false);");
87 }
88 var args = [evalCallbackResolve, evalCallbackReject].concat(argument sArray.map(JSON.stringify));
89 var functionCall = functionName + ".call(null, " + args.join(", ") + ")";
90 try {
91 eval(functionCall);
92 } catch(e) {
93 console.error(e);
pfeldman 2015/04/15 17:50:08 Inspector.addResult, no console.error please, they
dmurph 2015/04/15 21:29:32 Done. (This was copied from below, so I changed in
94 evalCallbackReject(e);
95 }
96 }
97 var pageRequest = "(" + asyncEvalWrapper.toString() + ")(" + id + ", une scape('" + escape(functionName) + "'), [" + jsonParameters.join(", ") + "])";
98 InspectorTest.evaluateInPage(pageRequest);
99 });
100 }
101
102
103 InspectorTest.didInvokePageFunctionPromise = function(callId, value, didResolve)
104 {
105 var callbacks = pendingPromiseEvalRequests[callId];
106 if (!callbacks) {
107 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?");
108 return;
109 }
110 var callback = didResolve ? callbacks.resolve : callbacks.reject;
111 delete pendingPromiseEvalRequests[callId];
112 callback(value);
113 }
114
61 InspectorTest.invokePageFunctionAsync = function(functionName, callback) 115 InspectorTest.invokePageFunctionAsync = function(functionName, callback)
62 { 116 {
63 var id = ++lastEvalId; 117 var id = ++lastEvalId;
64 pendingEvalRequests[id] = InspectorTest.safeWrap(callback); 118 pendingEvalRequests[id] = InspectorTest.safeWrap(callback);
65 var asyncEvalWrapper = function(callId, functionName) 119 var asyncEvalWrapper = function(callId, functionName)
66 { 120 {
67 function evalCallback(result) 121 function evalCallback(result)
68 { 122 {
69 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");"); 123 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");");
70 } 124 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 try { 476 try {
423 Array.prototype.push.call(arguments, result); 477 Array.prototype.push.call(arguments, result);
424 override.apply(this, arguments); 478 override.apply(this, arguments);
425 } catch (e) { 479 } catch (e) {
426 throw ("Exception in overriden method '" + methodName + "': " + e); 480 throw ("Exception in overriden method '" + methodName + "': " + e);
427 } 481 }
428 return result; 482 return result;
429 }; 483 };
430 } 484 }
431 485
486 InspectorTest.addSnifferPromise = function(receiver, methodName)
487 {
488 return new Promise(function (resolve, reject) {
489 var original = receiver[methodName];
pfeldman 2015/04/15 17:50:08 Poor indent.
dmurph 2015/04/15 21:29:32 Done.
490 if (typeof original !== "function") {
491 reject("Cannot find method to override: " + methodName);
492 return;
493 }
494
495 receiver[methodName] = function(var_args) {
496 try {
497 var result = original.apply(this, arguments);
498 } finally {
499 receiver[methodName] = original;
500 }
501 // In case of exception the override won't be called.
502 try {
503 Array.prototype.push.call(arguments, result);
504 resolve.apply(this, arguments);
505 } catch (e) {
506 reject("Exception in overriden method '" + methodName + "': " + e);
507 }
508 return result;
509 };
510 });
511 }
512
432 InspectorTest.addConsoleSniffer = function(override, opt_sticky) 513 InspectorTest.addConsoleSniffer = function(override, opt_sticky)
433 { 514 {
434 InspectorTest.addSniffer(WebInspector.ConsoleModel.prototype, "addMessage", override, opt_sticky); 515 InspectorTest.addSniffer(WebInspector.ConsoleModel.prototype, "addMessage", override, opt_sticky);
435 } 516 }
436 517
437 InspectorTest.override = function(receiver, methodName, override, opt_sticky) 518 InspectorTest.override = function(receiver, methodName, override, opt_sticky)
438 { 519 {
439 override = InspectorTest.safeWrap(override); 520 override = InspectorTest.safeWrap(override);
440 521
441 var original = receiver[methodName]; 522 var original = receiver[methodName];
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 _output("[page] " + text); 1055 _output("[page] " + text);
975 } 1056 }
976 1057
977 function _output(result) 1058 function _output(result)
978 { 1059 {
979 if (!outputElement) 1060 if (!outputElement)
980 createOutputElement(); 1061 createOutputElement();
981 outputElement.appendChild(document.createTextNode(result)); 1062 outputElement.appendChild(document.createTextNode(result));
982 outputElement.appendChild(document.createElement("br")); 1063 outputElement.appendChild(document.createElement("br"));
983 } 1064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698