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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html

Issue 2207973003: [DevTools] Removed InspectorTest.invokePageFunctionPromise from protocol tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/animation/animation-pause.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright (C) 2012 Samsung Electronics. All rights reserved. 2 Copyright (C) 2012 Samsung Electronics. All rights reserved.
3 3
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 7
8 1. Redistributions of source code must retain the above copyright 8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer. 9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright 10 2. Redistributions in binary form must reproduce the above copyright
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 351
352 InspectorTest.pageReloaded = function() 352 InspectorTest.pageReloaded = function()
353 { 353 {
354 InspectorTest.log("Page reloaded."); 354 InspectorTest.log("Page reloaded.");
355 var callback = InspectorTest._pageLoadedCallback; 355 var callback = InspectorTest._pageLoadedCallback;
356 delete InspectorTest._pageLoadedCallback; 356 delete InspectorTest._pageLoadedCallback;
357 if (callback) 357 if (callback)
358 callback(); 358 callback();
359 } 359 }
360 360
361 var lastPromiseEvalId = 0;
362 var pendingPromiseEvalRequests = {};
363
364 /**
365 * The given function should take two callback paraters before the arguments:
366 * * resolve - called when successful (with optional result)
367 * * reject - called when there was a failure (with optional error)
368 */
369 InspectorTest.invokePageFunctionPromise = function(functionName, parameters)
370 {
371 return new Promise(function(resolve, reject) {
372 var id = ++lastPromiseEvalId;
373 pendingPromiseEvalRequests[id] = { resolve: InspectorTest.safeWrap(resol ve), reject: InspectorTest.safeWrap(reject) };
374
375 var jsonParameters = [];
376 for (var i = 0; i < parameters.length; ++i)
377 jsonParameters.push(JSON.stringify(parameters[i]));
378 var asyncEvalWrapper = function(callId, functionName, argumentsArray)
379 {
380 function evalCallbackResolve(result)
381 {
382 testRunner.evaluateInWebInspector(2, "InspectorTest.didInvokePag eFunctionPromise(" + callId + ", " + JSON.stringify(result) + ", true);");
383 }
384
385 function evalCallbackReject(result)
386 {
387 testRunner.evaluateInWebInspector(2, "InspectorTest.didInvokePag eFunctionPromise(" + callId + ", " + JSON.stringify(result) + ", false);");
388 }
389
390 var args = [evalCallbackResolve, evalCallbackReject].concat(argument sArray.map(JSON.stringify));
391 var functionCall = functionName + ".call(null, " + args.join(", ") + ")";
392 try {
393 eval(functionCall);
394 } catch(e) {
395 InspectorTest.log("Error: " + e);
396 evalCallbackReject(e);
397 }
398 }
399 var pageRequest = "(" + asyncEvalWrapper.toString() + ")(" + id + ", une scape('" + escape(functionName) + "'), [" + jsonParameters.join(", ") + "])";
400 InspectorTest.evaluateInPage(pageRequest);
401 });
402 }
403
404 InspectorTest.didInvokePageFunctionPromise = function(callId, value, didResolve)
405 {
406 var callbacks = pendingPromiseEvalRequests[callId];
407 if (!callbacks) {
408 InspectorTest.log("Missing callback for async eval " + callId + ", perha ps callback invoked twice?");
409 return;
410 }
411 var callback = didResolve ? callbacks.resolve : callbacks.reject;
412 delete pendingPromiseEvalRequests[callId];
413 callback(value);
414 }
415
416 window.addEventListener("load", InspectorTest.readyForTest.bind(InspectorTest), false); 361 window.addEventListener("load", InspectorTest.readyForTest.bind(InspectorTest), false);
417 362
418 </script> 363 </script>
419 </head> 364 </head>
420 </html> 365 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/animation/animation-pause.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698