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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js

Issue 2931143003: DevTools: make debugger's rawLocationToUILocation return nullable type (Closed)
Patch Set: add test Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
index 5aa17a07cb64232e7e449620655a49636158f961..8986ab84dae83751b384ebe61c3750131be72f78 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/bindings/bindings-test.js
@@ -148,6 +148,39 @@ InspectorTest.waitForSourceMap = function(sourceMapURLSuffix) {
return promise;
}
+var locationPool = new Bindings.LiveLocationPool();
+var nameSymbol = Symbol('LiveLocationNameForTest');
+var createdSymbol = Symbol('LiveLocationCreated');
+
+InspectorTest.createDebuggerLiveLocation = function(name, urlSuffix, lineNumber, columnNumber) {
+ var script = InspectorTest.debuggerModel.scripts().find(script => script.sourceURL.endsWith(urlSuffix));
+ var rawLocation = InspectorTest.debuggerModel.createRawLocation(script, lineNumber || 0, columnNumber || 0);
+ return Bindings.debuggerWorkspaceBinding.createLiveLocation(rawLocation, updateDelegate.bind(null, name), locationPool);
+}
+
+InspectorTest.createCSSLiveLocation = function(name, urlSuffix, lineNumber, columnNumber) {
+ var header = InspectorTest.cssModel.styleSheetHeaders().find(header => header.resourceURL().endsWith(urlSuffix));
+ var rawLocation = new SDK.CSSLocation(header, lineNumber || 0, columnNumber || 0);
+ return Bindings.cssWorkspaceBinding.createLiveLocation(rawLocation, updateDelegate.bind(null, name), locationPool);
+}
+
+function updateDelegate(name, liveLocation) {
+ liveLocation[nameSymbol] = name;
+ var hint = liveLocation[createdSymbol] ? '[ UPDATE ]' : '[ CREATE ]';
+ liveLocation[createdSymbol] = true;
+ InspectorTest.dumpLocation(liveLocation, hint);
+}
+
+InspectorTest.dumpLocation = function(liveLocation, hint) {
+ hint = hint || '[ GET ]';
+ var prefix = `${hint} LiveLocation-${liveLocation[nameSymbol]}: `;
+ var uiLocation = liveLocation.uiLocation();
+ if (!uiLocation) {
+ InspectorTest.addResult(prefix + 'null');
+ return;
+ }
+ InspectorTest.addResult(prefix + uiLocation.uiSourceCode.url() + ':' + uiLocation.lineNumber + ':' + uiLocation.columnNumber);
+}
}

Powered by Google App Engine
This is Rietveld 408576698