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

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

Issue 881263002: DevTools: use target-based model accessors only. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 console.log = consoleOutputHook.bind(InspectorTest, "log"); 10 console.log = consoleOutputHook.bind(InspectorTest, "log");
(...skipping 24 matching lines...) Expand all
35 results = []; 35 results = [];
36 } 36 }
37 37
38 InspectorTest.evaluateInPage = function(code, callback) 38 InspectorTest.evaluateInPage = function(code, callback)
39 { 39 {
40 callback = InspectorTest.safeWrap(callback); 40 callback = InspectorTest.safeWrap(callback);
41 41
42 function mycallback(error, result, wasThrown) 42 function mycallback(error, result, wasThrown)
43 { 43 {
44 if (!error) 44 if (!error)
45 callback(WebInspector.runtimeModel.createRemoteObject(result), wasTh rown); 45 callback(InspectorTest.runtimeModel.createRemoteObject(result), wasT hrown);
46 } 46 }
47 InspectorTest.RuntimeAgent.evaluate(code, "console", false, mycallback); 47 InspectorTest.RuntimeAgent.evaluate(code, "console", false, mycallback);
48 } 48 }
49 49
50 InspectorTest.evaluateInPageWithTimeout = function(code) 50 InspectorTest.evaluateInPageWithTimeout = function(code)
51 { 51 {
52 // FIXME: we need a better way of waiting for chromium events to happen 52 // FIXME: we need a better way of waiting for chromium events to happen
53 InspectorTest.evaluateInPage("setTimeout(unescape('" + escape(code) + "'), 1 )"); 53 InspectorTest.evaluateInPage("setTimeout(unescape('" + escape(code) + "'), 1 )");
54 } 54 }
55 55
56 var lastEvalId = 0; 56 var lastEvalId = 0;
57 var pendingEvalRequests = {}; 57 var pendingEvalRequests = {};
58 58
59 InspectorTest.invokePageFunctionAsync = function(functionName, callback) 59 InspectorTest.invokePageFunctionAsync = function(functionName, callback)
60 { 60 {
61 var id = ++lastEvalId; 61 var id = ++lastEvalId;
62 pendingEvalRequests[id] = InspectorTest.safeWrap(callback); 62 pendingEvalRequests[id] = InspectorTest.safeWrap(callback);
63 var asyncEvalWrapper = function(callId, functionName) 63 var asyncEvalWrapper = function(callId, functionName)
64 { 64 {
65 function evalCallback(result) 65 function evalCallback(result)
66 { 66 {
67 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");"); 67 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");");
68 } 68 }
69 eval(functionName + "(" + evalCallback + ")"); 69 try {
70 eval(functionName + "(" + evalCallback + ")");
71 } catch(e) {
72 console.error(e);
73 evalCallback(String(e));
74 }
70 } 75 }
71 InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "'))"); 76 InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "'))");
72 } 77 }
73 78
74 InspectorTest.didInvokePageFunctionAsync = function(callId, value) 79 InspectorTest.didInvokePageFunctionAsync = function(callId, value)
75 { 80 {
76 var callback = pendingEvalRequests[callId]; 81 var callback = pendingEvalRequests[callId];
77 if (!callback) { 82 if (!callback) {
78 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); 83 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?");
79 return; 84 return;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 for (var timeoutId in this._timeoutIdToProcess) 666 for (var timeoutId in this._timeoutIdToProcess)
662 this._timeoutIdToProcess[timeoutId].call(window); 667 this._timeoutIdToProcess[timeoutId].call(window);
663 this._timeoutIdToProcess = {}; 668 this._timeoutIdToProcess = {};
664 this._timeoutIdToMillis = {}; 669 this._timeoutIdToMillis = {};
665 } 670 }
666 } 671 }
667 672
668 WebInspector.targetManager.observeTargets({ 673 WebInspector.targetManager.observeTargets({
669 targetAdded: function(target) 674 targetAdded: function(target)
670 { 675 {
671 if (!WebInspector.domModel) 676 if (InspectorTest.CSSAgent)
672 WebInspector.domModel = target.domModel; 677 return;
673 if (!WebInspector.consoleModel) 678 InspectorTest.CSSAgent = target.cssAgent();
674 WebInspector.consoleModel = target.consoleModel; 679 InspectorTest.CanvasAgent = target.canvasAgent();
675 if (!WebInspector.networkManager) 680 InspectorTest.ConsoleAgent = target.consoleAgent();
676 WebInspector.networkManager = target.networkManager; 681 InspectorTest.DOMAgent = target.domAgent();
677 if (!WebInspector.timelineManager) 682 InspectorTest.DOMDebuggerAgent = target.domdebuggerAgent();
678 WebInspector.timelineManager = target.timelineManager; 683 InspectorTest.DebuggerAgent = target.debuggerAgent();
684 InspectorTest.HeapProfilerAgent = target.heapProfilerAgent();
685 InspectorTest.InspectorAgent = target.inspectorAgent();
686 InspectorTest.LayerTreeAgent = target.layerTreeAgent();
687 InspectorTest.NetworkAgent = target.networkAgent();
688 InspectorTest.PageAgent = target.pageAgent();
689 InspectorTest.ProfilerAgent = target.profilerAgent();
690 InspectorTest.RuntimeAgent = target.runtimeAgent();
691 InspectorTest.WorkerAgent = target.workerAgent();
692
693 InspectorTest.consoleModel = target.consoleModel;
694 InspectorTest.networkManager = target.networkManager;
695 InspectorTest.resourceTreeModel = target.resourceTreeModel;
696 InspectorTest.networkLog = target.networkLog;
697 InspectorTest.debuggerModel = target.debuggerModel;
698 InspectorTest.runtimeModel = target.runtimeModel;
699 InspectorTest.domModel = target.domModel;
700 InspectorTest.cssModel = target.cssModel;
701 InspectorTest.workerManager = target.workerManager;
702 InspectorTest.powerProfiler = target.powerProfiler;
703 InspectorTest.databaseModel = target.databaseModel;
704 InspectorTest.domStorageModel = target.domStorageModel;
705 InspectorTest.cpuProfilerModel = target.cpuProfilerModel;
706 InspectorTest.heapProfilerModel = target.heapProfilerModel;
707 InspectorTest.indexedDBModel = target.indexedDBModel;
708 InspectorTest.layerTreeModel = target.layerTreeModel;
709 InspectorTest.animationModel = target.animationModel;
710 InspectorTest.serviceWorkerCacheModel = target.serviceWorkerCacheModel;
679 }, 711 },
680 712
681 targetRemoved: function(target) { } 713 targetRemoved: function(target) { }
682 }); 714 });
683 715
684 InspectorTest._panelsToPreload = []; 716 InspectorTest._panelsToPreload = [];
685 717
686 InspectorTest.preloadPanel = function(panelName) 718 InspectorTest.preloadPanel = function(panelName)
687 { 719 {
688 InspectorTest._panelsToPreload.push(panelName); 720 InspectorTest._panelsToPreload.push(panelName);
689 } 721 }
690 722
691 InspectorTest.CSSAgent = WebInspector.targetManager.mainTarget().cssAgent();
692 InspectorTest.CanvasAgent = WebInspector.targetManager.mainTarget().canvasAgent( );
693 InspectorTest.ConsoleAgent = WebInspector.targetManager.mainTarget().consoleAgen t();
694 InspectorTest.DOMAgent = WebInspector.targetManager.mainTarget().domAgent();
695 InspectorTest.DOMDebuggerAgent = WebInspector.targetManager.mainTarget().domdebu ggerAgent();
696 InspectorTest.DebuggerAgent = WebInspector.targetManager.mainTarget().debuggerAg ent();
697 InspectorTest.HeapProfilerAgent = WebInspector.targetManager.mainTarget().heapPr ofilerAgent();
698 InspectorTest.InspectorAgent = WebInspector.targetManager.mainTarget().inspector Agent();
699 InspectorTest.LayerTreeAgent = WebInspector.targetManager.mainTarget().layerTree Agent();
700 InspectorTest.NetworkAgent = WebInspector.targetManager.mainTarget().networkAgen t();
701 InspectorTest.PageAgent = WebInspector.targetManager.mainTarget().pageAgent();
702 InspectorTest.ProfilerAgent = WebInspector.targetManager.mainTarget().profilerAg ent();
703 InspectorTest.RuntimeAgent = WebInspector.targetManager.mainTarget().runtimeAgen t();
704 InspectorTest.WorkerAgent = WebInspector.targetManager.mainTarget().workerAgent( );
705
706 }; // initialize_InspectorTest 723 }; // initialize_InspectorTest
707 724
708 var initializeCallId = 0; 725 var initializeCallId = 0;
709 var runTestCallId = 1; 726 var runTestCallId = 1;
710 var evalCallbackCallId = 2; 727 var evalCallbackCallId = 2;
711 var frontendReopeningCount = 0; 728 var frontendReopeningCount = 0;
712 729
713 function reopenFrontend() 730 function reopenFrontend()
714 { 731 {
715 closeFrontend(openFrontendAndIncrement); 732 closeFrontend(openFrontendAndIncrement);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 _output("[page] " + text); 921 _output("[page] " + text);
905 } 922 }
906 923
907 function _output(result) 924 function _output(result)
908 { 925 {
909 if (!outputElement) 926 if (!outputElement)
910 createOutputElement(); 927 createOutputElement();
911 outputElement.appendChild(document.createTextNode(result)); 928 outputElement.appendChild(document.createTextNode(result));
912 outputElement.appendChild(document.createElement("br")); 929 outputElement.appendChild(document.createElement("br"));
913 } 930 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698