| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../inspector-test.js"></script> |
| 4 <script src="../isolated-filesystem-test.js"></script> |
| 5 <script src="../debugger-test.js"></script> |
| 6 <script src="./persistence-test.js"></script> |
| 7 <script src="./automapping-test.js"></script> |
| 8 <style> |
| 9 body { |
| 10 color: red; |
| 11 } |
| 12 /*# sourceURL=http://127.0.0.1:8000/simple.css */ |
| 13 </style> |
| 14 <script> |
| 15 |
| 16 function test() |
| 17 { |
| 18 var fsUISourceCode, fs; |
| 19 |
| 20 InspectorTest.runTestSuite([ |
| 21 function initializeTestFileSystem(next) |
| 22 { |
| 23 InspectorTest.waitForUISourceCode('simple.css') |
| 24 .then(uiSourceCode => uiSourceCode.requestContent()) |
| 25 .then(onCSSContent); |
| 26 |
| 27 function onCSSContent(content) |
| 28 { |
| 29 fs = new InspectorTest.TestFileSystem("file:///var/www"); |
| 30 InspectorTest.addFiles(fs, { "simple.css": { content: content },
}); |
| 31 fs.reportCreated(next); |
| 32 } |
| 33 }, |
| 34 |
| 35 function waitForPersistenceBinding(next) |
| 36 { |
| 37 Workspace.fileSystemMapping.addFileMapping(fs.fileSystemPath, "http:
//127.0.0.1:8000/", "/"); |
| 38 InspectorTest.waitForBinding('simple.css').then(onBinding); |
| 39 |
| 40 function onBinding(binding) |
| 41 { |
| 42 fsUISourceCode = binding.fileSystem; |
| 43 fsUISourceCode.requestContent().then(onContent); |
| 44 } |
| 45 |
| 46 function onContent(content) { |
| 47 InspectorTest.addResult('Initial content of file:///var/www/simp
le.css'); |
| 48 InspectorTest.addResult('----\n' + content + '\n----'); |
| 49 next(); |
| 50 } |
| 51 }, |
| 52 |
| 53 function breakCSSModelProtocol(next) |
| 54 { |
| 55 // Nullify console.error since it dumps style sheet Ids and make tes
t flake. |
| 56 console.error = function() { }; |
| 57 |
| 58 var styleSheet = InspectorTest.cssModel.styleSheetHeaders().find(hea
der => header.contentURL().endsWith('simple.css')); |
| 59 // Make CSSModel constantly return errors on all getStyleSheetText r
equests. |
| 60 InspectorTest.override(InspectorTest.cssModel._agent, 'getStyleSheet
Text', throwProtocolError, true); |
| 61 // Set a new stylesheet text |
| 62 InspectorTest.cssModel.setStyleSheetText(styleSheet.id, 'body {color
: blue}'); |
| 63 // Expect StylesSourceMapping to sync styleSheet with network UISour
ceCode. |
| 64 // Persistence acts synchronously. |
| 65 InspectorTest.addSniffer(Bindings.StylesSourceMapping.prototype, '_s
tyleFileSyncedForTest', next); |
| 66 |
| 67 function throwProtocolError(styleSheetId, textCallback) { |
| 68 var error = 'FAKE PROTOCOL ERROR'; |
| 69 var result = textCallback(error); |
| 70 InspectorTest.addResult('Protocol Error: ' + error); |
| 71 return Promise.resolve(result); |
| 72 } |
| 73 }, |
| 74 |
| 75 function onStylesSourcemappingSynced(next) { |
| 76 InspectorTest.addResult('Updated content of file:///var/www/simple.c
ss'); |
| 77 InspectorTest.addResult('----\n' + fsUISourceCode.content() + '\n---
-'); |
| 78 next() |
| 79 } |
| 80 ]); |
| 81 } |
| 82 </script> |
| 83 </head> |
| 84 <body onload="runTest()"> |
| 85 <p>Verify that persistence does not overwrite CSS files when CSS model reports e
rror on getStyleSheetText.</p> |
| 86 </body> |
| 87 </html> |
| OLD | NEW |