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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css.html

Issue 2702583003: DevTools: do not assign empty content to CSS UISourceCode in case of protocol error (Closed)
Patch Set: fix test Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css.html b/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css.html
new file mode 100644
index 0000000000000000000000000000000000000000..def843e660f272361de720984707c92b0afad291
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css.html
@@ -0,0 +1,87 @@
+<html>
+<head>
+<script src="../inspector-test.js"></script>
+<script src="../isolated-filesystem-test.js"></script>
+<script src="../debugger-test.js"></script>
+<script src="./persistence-test.js"></script>
+<script src="./automapping-test.js"></script>
+<style>
+body {
+ color: red;
+}
+/*# sourceURL=http://127.0.0.1:8000/simple.css */
+</style>
+<script>
+
+function test()
+{
+ var fsUISourceCode, fs;
+
+ InspectorTest.runTestSuite([
+ function initializeTestFileSystem(next)
+ {
+ InspectorTest.waitForUISourceCode('simple.css')
+ .then(uiSourceCode => uiSourceCode.requestContent())
+ .then(onCSSContent);
+
+ function onCSSContent(content)
+ {
+ fs = new InspectorTest.TestFileSystem("file:///var/www");
+ InspectorTest.addFiles(fs, { "simple.css": { content: content }, });
+ fs.reportCreated(next);
+ }
+ },
+
+ function waitForPersistenceBinding(next)
+ {
+ Workspace.fileSystemMapping.addFileMapping(fs.fileSystemPath, "http://127.0.0.1:8000/", "/");
+ InspectorTest.waitForBinding('simple.css').then(onBinding);
+
+ function onBinding(binding)
+ {
+ fsUISourceCode = binding.fileSystem;
+ fsUISourceCode.requestContent().then(onContent);
+ }
+
+ function onContent(content) {
+ InspectorTest.addResult('Initial content of file:///var/www/simple.css');
+ InspectorTest.addResult('----\n' + content + '\n----');
+ next();
+ }
+ },
+
+ function breakCSSModelProtocol(next)
+ {
+ // Nullify console.error since it dumps style sheet Ids and make test flake.
+ console.error = function() { };
+
+ var styleSheet = InspectorTest.cssModel.styleSheetHeaders().find(header => header.contentURL().endsWith('simple.css'));
+ // Make CSSModel constantly return errors on all getStyleSheetText requests.
+ InspectorTest.override(InspectorTest.cssModel._agent, 'getStyleSheetText', throwProtocolError, true);
+ // Set a new stylesheet text
+ InspectorTest.cssModel.setStyleSheetText(styleSheet.id, 'body {color: blue}');
+ // Expect StylesSourceMapping to sync styleSheet with network UISourceCode.
+ // Persistence acts synchronously.
+ InspectorTest.addSniffer(Bindings.StylesSourceMapping.prototype, '_styleFileSyncedForTest', next);
+
+ function throwProtocolError(styleSheetId, textCallback) {
+ var error = 'FAKE PROTOCOL ERROR';
+ var result = textCallback(error);
+ InspectorTest.addResult('Protocol Error: ' + error);
+ return Promise.resolve(result);
+ }
+ },
+
+ function onStylesSourcemappingSynced(next) {
+ InspectorTest.addResult('Updated content of file:///var/www/simple.css');
+ InspectorTest.addResult('----\n' + fsUISourceCode.content() + '\n----');
+ next()
+ }
+ ]);
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Verify that persistence does not overwrite CSS files when CSS model reports error on getStyleSheetText.</p>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/persistence/persistence-do-not-overwrite-css-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698