OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
5 <script src="../../../http/tests/inspector/workspace-test.js"></script> | 5 <script src="../../../http/tests/inspector/workspace-test.js"></script> |
6 <script> | 6 <script> |
7 function test() | 7 function test() |
8 { | 8 { |
9 var mockContentsMap = {}; | 9 var mockContentsMap = {}; |
10 var lastResourceId = 0; | 10 var lastResourceId = 0; |
| 11 var lastStyleSheetId = 0; |
11 | 12 |
12 var mockStyleSheetHeader = { | 13 |
13 styleSheetId: "1", | 14 function createMockStyleSheetHeader(url) |
14 sourceURL: "foo.css", | 15 { |
15 sourceMapURL: "", | 16 return { |
16 origin: "regular", | 17 styleSheetId: (++lastStyleSheetId) + "", |
17 title: "", | 18 sourceURL: url, |
18 disabled: false | 19 sourceMapURL: "", |
19 }; | 20 origin: "regular", |
| 21 title: "", |
| 22 disabled: false |
| 23 }; |
| 24 } |
20 | 25 |
21 NetworkAgent.getResponseBody = function(requestId, callback) | 26 NetworkAgent.getResponseBody = function(requestId, callback) |
22 { | 27 { |
23 callback(undefined, mockContentsMap[requestId], false); | 28 callback(undefined, mockContentsMap[requestId], false); |
24 } | 29 } |
25 | 30 |
26 PageAgent.getResourceContent = function(frameId, url, callback) | 31 PageAgent.getResourceContent = function(frameId, url, callback) |
27 { | 32 { |
28 callback(undefined, mockContentsMap[url], false); | 33 callback(undefined, mockContentsMap[url], false); |
29 } | 34 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 InspectorTest.addResult("Creating resource."); | 136 InspectorTest.addResult("Creating resource."); |
132 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed); | 137 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed); |
133 createResourceMock(WebInspector.resourceTypes.Stylesheet, "<styleshe
et resource content>"); | 138 createResourceMock(WebInspector.resourceTypes.Stylesheet, "<styleshe
et resource content>"); |
134 | 139 |
135 function uiSourceCodeAdded(uiSourceCode) | 140 function uiSourceCodeAdded(uiSourceCode) |
136 { | 141 { |
137 InspectorTest.dumpUISourceCode(uiSourceCode, next); | 142 InspectorTest.dumpUISourceCode(uiSourceCode, next); |
138 } | 143 } |
139 }, | 144 }, |
140 | 145 |
141 function testRemoveStyleSheetFromModel(next) | 146 function testRemoveStyleSheetFromModelWithComplexURL(next) |
142 { | 147 { |
143 var networkUISourceCodeProvider = createNetworkUISourceCodeProvider(
); | 148 var mockStyleSheetHeader = createMockStyleSheetHeader("http://exampl
e.com/foo.css"); |
144 var target = WebInspector.targetManager.mainTarget(); | 149 testRemoveStyleSheetFromModel(mockStyleSheetHeader, next); |
145 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdd
ed); | 150 }, |
146 target.cssModel._styleSheetAdded(mockStyleSheetHeader); | |
147 | 151 |
148 function uiSourceCodeAdded(uiSourceCode) | 152 function testRemoveStyleSheetFromModelWithSimpleURL(next) |
149 { | 153 { |
150 InspectorTest.addResult("Added uiSourceCode: " + InspectorTest.u
iSourceCodeURL(uiSourceCode)); | 154 var mockStyleSheetHeader = createMockStyleSheetHeader("foo.css"); |
151 InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent(uiSourceC
odeRemoved); | 155 testRemoveStyleSheetFromModel(mockStyleSheetHeader, next); |
152 target.cssModel._styleSheetRemoved(mockStyleSheetHeader.styleShe
etId); | |
153 } | |
154 | |
155 function uiSourceCodeRemoved(uiSourceCode) | |
156 { | |
157 InspectorTest.addResult("Removed uiSourceCode: " + InspectorTest
.uiSourceCodeURL(uiSourceCode)); | |
158 next(); | |
159 } | |
160 } | 156 } |
161 ]); | 157 ]); |
| 158 |
| 159 function testRemoveStyleSheetFromModel(mockStyleSheetHeader, callback) |
| 160 { |
| 161 var networkUISourceCodeProvider = createNetworkUISourceCodeProvider(); |
| 162 var target = WebInspector.targetManager.mainTarget(); |
| 163 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded); |
| 164 target.cssModel._styleSheetAdded(mockStyleSheetHeader); |
| 165 |
| 166 function uiSourceCodeAdded(uiSourceCode) |
| 167 { |
| 168 InspectorTest.addResult("Added uiSourceCode: " + InspectorTest.uiSou
rceCodeURL(uiSourceCode)); |
| 169 InspectorTest.waitForWorkspaceUISourceCodeRemovedEvent(uiSourceCodeR
emoved); |
| 170 target.cssModel._styleSheetRemoved(mockStyleSheetHeader.styleSheetId
); |
| 171 } |
| 172 |
| 173 function uiSourceCodeRemoved(uiSourceCode) |
| 174 { |
| 175 InspectorTest.addResult("Removed uiSourceCode: " + InspectorTest.uiS
ourceCodeURL(uiSourceCode)); |
| 176 callback(); |
| 177 } |
| 178 } |
162 }; | 179 }; |
163 </script> | 180 </script> |
164 </head> | 181 </head> |
165 <body onload="runTest()"> | 182 <body onload="runTest()"> |
166 <p>Tests NetworkUISourceCodeProvider class.</p> | 183 <p>Tests NetworkUISourceCodeProvider class.</p> |
167 </body> | 184 </body> |
168 </html> | 185 </html> |
OLD | NEW |