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

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

Issue 2392433003: DevTools: Catch async errors in unit tests (Closed)
Patch Set: Style Created 4 years, 2 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/http/tests/inspector-unit/test-failure.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 var UnitTest = {}; 1 var UnitTest = {};
2 (function() 2 (function()
3 { 3 {
4 var oldLoadResourcePromise = Runtime.loadResourcePromise; 4 var oldLoadResourcePromise = Runtime.loadResourcePromise;
5 Runtime.loadResourcePromise = function(url) 5 Runtime.loadResourcePromise = function(url)
6 { 6 {
7 if (url.startsWith("/")) 7 if (url.startsWith("/"))
8 return oldLoadResourcePromise(url); 8 return oldLoadResourcePromise(url);
9 9
10 if (!url.startsWith("http://")) 10 if (!url.startsWith("http://"))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 UnitTest.addResult = function(text) 51 UnitTest.addResult = function(text)
52 { 52 {
53 if (window.testRunner) 53 if (window.testRunner)
54 results.push(String(text)); 54 results.push(String(text));
55 else 55 else
56 console.log(text); 56 console.log(text);
57 } 57 }
58 58
59 function completeTestOnError(message, source, lineno, colno, error)
60 {
61 UnitTest.addResult("TEST ENDED IN ERROR: " + error.stack);
62 UnitTest.completeTest();
63 }
64 window.onerror = completeTestOnError;
65
59 Runtime.startApplication("/inspector-unit/inspector-unit-test").then(runTest ); 66 Runtime.startApplication("/inspector-unit/inspector-unit-test").then(runTest );
60 67
61 function runTest() 68 function runTest()
62 { 69 {
63 var description = document.body.textContent.trim(); 70 var description = document.body.textContent.trim();
64 if (description) 71 if (description)
65 UnitTest.addResult(description); 72 UnitTest.addResult(description);
66 73
67 WebInspector.settings = new WebInspector.Settings(new WebInspector.Setti ngsStorage( 74 WebInspector.settings = new WebInspector.Settings(new WebInspector.Setti ngsStorage(
68 {}, 75 {},
69 InspectorFrontendHost.setPreference, 76 InspectorFrontendHost.setPreference,
70 InspectorFrontendHost.removePreference, 77 InspectorFrontendHost.removePreference,
71 InspectorFrontendHost.clearPreferences)); 78 InspectorFrontendHost.clearPreferences));
72 79
73 WebInspector.viewManager = new WebInspector.ViewManager(); 80 WebInspector.viewManager = new WebInspector.ViewManager();
74 WebInspector.initializeUIUtils(document, WebInspector.settings.createSet ting("uiTheme", "default")); 81 WebInspector.initializeUIUtils(document, WebInspector.settings.createSet ting("uiTheme", "default"));
75 82
76 WebInspector.zoomManager = new WebInspector.ZoomManager(window, Inspecto rFrontendHost); 83 WebInspector.zoomManager = new WebInspector.ZoomManager(window, Inspecto rFrontendHost);
77 WebInspector.inspectorView = WebInspector.InspectorView.instance(); 84 WebInspector.inspectorView = WebInspector.InspectorView.instance();
78 WebInspector.ContextMenu.initialize(); 85 WebInspector.ContextMenu.initialize();
79 WebInspector.ContextMenu.installHandler(document); 86 WebInspector.ContextMenu.installHandler(document);
80 WebInspector.Tooltip.installHandler(document); 87 WebInspector.Tooltip.installHandler(document);
81 88
82 var rootView = new WebInspector.RootView(); 89 var rootView = new WebInspector.RootView();
83 WebInspector.inspectorView.show(rootView.element); 90 WebInspector.inspectorView.show(rootView.element);
84 WebInspector.inspectorView.showInitialPanel(); 91 WebInspector.inspectorView.showInitialPanel();
85 rootView.attachToDocument(document); 92 rootView.attachToDocument(document);
86 93
87 try { 94 test();
88 test();
89 } catch (e) {
90 UnitTest.addResult("TEST ENDED IN ERROR: " + e.stack);
91 UnitTest.completeTest();
92 }
93 } 95 }
94 })(); 96 })();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/test-failure.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698