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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/stylesheet-source-mapping.html

Issue 2533073003: [DevTools] Remove workspace-test.js part1. (Closed)
Patch Set: Created 4 years 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 <html> 1 <html>
2 <head> 2 <head>
3 <script src="inspector-test.js"></script> 3 <script src="inspector-test.js"></script>
4 <script src="debugger-test.js"></script> 4 <script src="debugger-test.js"></script>
5 <script src="workspace-test.js"></script>
6 5
7 <script> 6 <script>
7 function addStyleSheet()
8 {
9 var style = document.createElement("link");
10 style.setAttribute("rel", "stylesheet");
11 style.setAttribute("type", "text/css");
12 style.setAttribute("href", "http://127.0.0.1:8000/inspector/resources/exampl e.css");
13 document.head.appendChild(style);
14 }
15
8 function test() 16 function test()
9 { 17 {
10 var contentReceived; 18 var contentReceived;
11 var finalMappedLocation; 19 var finalMappedLocation;
12 var target = InspectorTest.createWorkspaceWithTarget(); 20 var target = InspectorTest.mainTarget;
13 var cssModel = SDK.CSSModel.fromTarget(target); 21 var cssModel = SDK.CSSModel.fromTarget(target);
14 Bindings.cssWorkspaceBinding = InspectorTest.testCSSWorkspaceBinding;
15 22
16 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(cssUISourceCodeAdded); 23 const styleSheetURL = "http://127.0.0.1:8000/inspector/resources/example.css ";
17 const styleSheetURL = "http://localhost:8000/inspector/resources/example.css "; 24 const sourceURL = "http://127.0.0.1:8000/inspector/resources/example.scss";
18 const sourceMapURL = "example.css.map"; 25 var styleSheetId;
19 const styleSheetId = "1";
20 26
21 InspectorTest.addSniffer(Bindings.CSSWorkspaceBinding.TargetInfo.prototype, "_updateLocations", locationsUpdated, true); 27 InspectorTest.waitForUISourceCode(cssUISourceCodeAdded, styleSheetURL);
22 cssModel._styleSheetAdded(createMockStyleSheetHeader(styleSheetURL, sourceMa pURL)); 28 InspectorTest.evaluateInPage("addStyleSheet()");
23 29
24 function locationsUpdated() 30 function locationsUpdated()
25 { 31 {
26 var header = cssModel.styleSheetHeaderForId(styleSheetId); 32 var header = cssModel.styleSheetHeaderForId(styleSheetId);
27 var uiLocation = InspectorTest.testCSSWorkspaceBinding.rawLocationToUILo cation(new SDK.CSSLocation(header, 2, 3)); 33 var uiLocation = Bindings.cssWorkspaceBinding.rawLocationToUILocation(ne w SDK.CSSLocation(header, 2, 3));
28 if (uiLocation.uiSourceCode.url().indexOf(".scss") === -1) 34 if (uiLocation.uiSourceCode.url().indexOf(".scss") === -1)
29 return; 35 return;
30 finalMappedLocation = uiLocation.uiSourceCode.url() + ":" + uiLocation.l ineNumber + ":" + uiLocation.columnNumber; 36 finalMappedLocation = uiLocation.uiSourceCode.url() + ":" + uiLocation.l ineNumber + ":" + uiLocation.columnNumber;
31 join(); 37 join();
32 } 38 }
33 39
34 function createMockStyleSheetHeader(url, sourceMapURL)
35 {
36 const frame = InspectorTest.resourceTreeModel.mainFrame;
37 return {
38 styleSheetId: styleSheetId,
39 frameId: frame.id,
40 sourceURL: url,
41 sourceMapURL: sourceMapURL,
42 origin: "regular",
43 title: "",
44 disabled: false
45 };
46 }
47
48 function createMockStyleSheetResource(url, mimeType, content)
49 {
50 const documentURL = "http://localhost:8000/inspector/stylesheet-source-m apping.html";
51 const frame = InspectorTest.resourceTreeModel.mainFrame;
52 var resource = new SDK.Resource(target, null, url, documentURL, frame.id , frame.loaderId, Common.resourceTypes.Stylesheet, mimeType);
53 resource.requestContent = function()
54 {
55 return Promise.resolve(content);
56 }
57 return resource;
58 }
59
60
61 function cssUISourceCodeAdded(uiSourceCode) 40 function cssUISourceCodeAdded(uiSourceCode)
62 { 41 {
42 styleSheetId = cssModel.styleSheetIdsForURL(styleSheetURL)[0];
43 InspectorTest.addSniffer(Bindings.CSSWorkspaceBinding.TargetInfo.prototy pe, "_updateLocations", locationsUpdated, true);
63 InspectorTest.addResult("Added CSS uiSourceCode: " + uiSourceCode.url()) ; 44 InspectorTest.addResult("Added CSS uiSourceCode: " + uiSourceCode.url()) ;
64 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(scssUISourceCodeAdd ed); 45 InspectorTest.waitForUISourceCode(scssUISourceCodeAdded, sourceURL);
65 } 46 }
66 47
67 function rawLocationToUILocation(line, column) 48 function rawLocationToUILocation(line, column)
68 { 49 {
69 var header = cssModel.styleSheetHeaderForId(styleSheetId); 50 var header = cssModel.styleSheetHeaderForId(styleSheetId);
70 return InspectorTest.testCSSWorkspaceBinding.rawLocationToUILocation(new SDK.CSSLocation(header, line, column)); 51 return Bindings.cssWorkspaceBinding.rawLocationToUILocation(new SDK.CSSL ocation(header, line, column));
71 } 52 }
72 53
73 function scssUISourceCodeAdded(uiSourceCode) 54 function scssUISourceCodeAdded(uiSourceCode)
74 { 55 {
75 InspectorTest.addResult("Added SCSS uiSourceCode: " + uiSourceCode.url() ); 56 InspectorTest.addResult("Added SCSS uiSourceCode: " + uiSourceCode.url() );
76 var cssUISourceCode = InspectorTest.testWorkspace.uiSourceCodeForURL(sty leSheetURL); 57 var cssUISourceCode = Workspace.workspace.uiSourceCodeForURL(styleSheetU RL);
77 var scssUISourceCode = InspectorTest.testWorkspace.uiSourceCodeForURL("h ttp://localhost:8000/inspector/resources/example.scss"); 58 var scssUISourceCode = Workspace.workspace.uiSourceCodeForURL(sourceURL) ;
78 59
79 InspectorTest.checkUILocation(cssUISourceCode, 0, 3, rawLocationToUILoca tion(0, 3)); 60 InspectorTest.checkUILocation(cssUISourceCode, 0, 3, rawLocationToUILoca tion(0, 3));
80 InspectorTest.checkUILocation(scssUISourceCode, 1, 0, rawLocationToUILoc ation(1, 0)); 61 InspectorTest.checkUILocation(scssUISourceCode, 1, 0, rawLocationToUILoc ation(1, 0));
81 InspectorTest.checkUILocation(scssUISourceCode, 2, 2, rawLocationToUILoc ation(2, 4)); 62 InspectorTest.checkUILocation(scssUISourceCode, 2, 2, rawLocationToUILoc ation(2, 4));
82 InspectorTest.checkUILocation(scssUISourceCode, 2, 5, rawLocationToUILoc ation(2, 6)); 63 InspectorTest.checkUILocation(scssUISourceCode, 2, 5, rawLocationToUILoc ation(2, 6));
83 InspectorTest.checkUILocation(scssUISourceCode, 2, 7, rawLocationToUILoc ation(2, 9)); 64 InspectorTest.checkUILocation(scssUISourceCode, 2, 7, rawLocationToUILoc ation(2, 9));
84 InspectorTest.checkUILocation(scssUISourceCode, 2, 10, rawLocationToUILo cation(3, 7)); 65 InspectorTest.checkUILocation(scssUISourceCode, 2, 10, rawLocationToUILo cation(3, 7));
85 InspectorTest.checkUILocation(scssUISourceCode, 4, 2, rawLocationToUILoc ation(4, 8)); 66 InspectorTest.checkUILocation(scssUISourceCode, 4, 2, rawLocationToUILoc ation(4, 8));
86 InspectorTest.checkUILocation(scssUISourceCode, 4, 2, rawLocationToUILoc ation(4, 10)); 67 InspectorTest.checkUILocation(scssUISourceCode, 4, 2, rawLocationToUILoc ation(4, 10));
87 InspectorTest.checkUILocation(scssUISourceCode, 4, 11, rawLocationToUILo cation(4, 11)); 68 InspectorTest.checkUILocation(scssUISourceCode, 4, 11, rawLocationToUILo cation(4, 11));
(...skipping 19 matching lines...) Expand all
107 } 88 }
108 89
109 </script> 90 </script>
110 91
111 </head> 92 </head>
112 93
113 <body onload="runTest()"> 94 <body onload="runTest()">
114 <p>Tests SourceMap and StyleSheetMapping.</p> 95 <p>Tests SourceMap and StyleSheetMapping.</p>
115 </body> 96 </body>
116 </html> 97 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698