Title: [90993] trunk/LayoutTests
Revision
90993
Author
[email protected]
Date
2011-07-14 06:28:19 -0700 (Thu, 14 Jul 2011)

Log Message

Web Inspector: add test for css live edit.
https://bugs.webkit.org/show_bug.cgi?id=64454

Reviewed by Pavel Feldman.

* http/tests/inspector/inspector-test.js:
(initialize_InspectorTest.InspectorTest.showResource):
* http/tests/inspector/live-edit-test.js: Added.
(initialize_LiveEditTest.InspectorTest.replaceInSource):
(initialize_LiveEditTest):
* inspector/debugger/live-edit.html:
* inspector/styles/css-live-edit-expected.txt: Added.
* inspector/styles/css-live-edit.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90992 => 90993)


--- trunk/LayoutTests/ChangeLog	2011-07-14 12:15:56 UTC (rev 90992)
+++ trunk/LayoutTests/ChangeLog	2011-07-14 13:28:19 UTC (rev 90993)
@@ -1,3 +1,19 @@
+2011-07-13  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: add test for css live edit.
+        https://bugs.webkit.org/show_bug.cgi?id=64454
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/inspector-test.js:
+        (initialize_InspectorTest.InspectorTest.showResource):
+        * http/tests/inspector/live-edit-test.js: Added.
+        (initialize_LiveEditTest.InspectorTest.replaceInSource):
+        (initialize_LiveEditTest):
+        * inspector/debugger/live-edit.html:
+        * inspector/styles/css-live-edit-expected.txt: Added.
+        * inspector/styles/css-live-edit.html: Added.
+
 2011-07-14  Yuta Kitamura  <[email protected]>
 
         WebSocket: Add platform-specific test results for hybi tests

Modified: trunk/LayoutTests/http/tests/inspector/inspector-test.js (90992 => 90993)


--- trunk/LayoutTests/http/tests/inspector/inspector-test.js	2011-07-14 12:15:56 UTC (rev 90992)
+++ trunk/LayoutTests/http/tests/inspector/inspector-test.js	2011-07-14 13:28:19 UTC (rev 90993)
@@ -69,6 +69,24 @@
     InspectorTest.evaluateInPage("setTimeout(unescape('" + escape(code) + "'))");
 }
 
+InspectorTest.showResource = function(resourceURL, callback)
+{
+    callback = InspectorTest.safeWrap(callback);
+    for (var url in WebInspector.resourceTreeModel._resourcesByURL) {
+        if (url.indexOf(resourceURL) !== -1) {
+            var resource = WebInspector.resourceTreeModel._resourcesByURL[url];
+            WebInspector.panels.resources.showResource(resource, 1);
+            var sourceFrame = WebInspector.panels.resources._resourceViewForResource(resource);
+            if (sourceFrame.loaded)
+                callback(sourceFrame);
+            else
+                sourceFrame.addEventListener(WebInspector.SourceFrame.Events.Loaded, callback.bind(null, sourceFrame));
+            return;
+        }
+    }
+    InspectorTest.addSniffer(WebInspector.resourceTreeModel, "_bindResourceURL", InspectorTest.showResource.bind(InspectorTest, url, callback));
+};
+
 InspectorTest.addResult = function(text)
 {
     results.push(text);

Added: trunk/LayoutTests/http/tests/inspector/live-edit-test.js (0 => 90993)


--- trunk/LayoutTests/http/tests/inspector/live-edit-test.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2011-07-14 13:28:19 UTC (rev 90993)
@@ -0,0 +1,24 @@
+var initialize_LiveEditTest = function() {
+
+InspectorTest.replaceInSource = function(sourceFrame, string, replacement, callback)
+{
+    sourceFrame._textViewer._mainPanel.readOnly = false;
+    sourceFrame.beforeTextChanged();
+    var oldRange, newRange;
+    var lines = sourceFrame._textModel._lines;
+    for (var i = 0; i < lines.length; ++i) {
+        var column = lines[i].indexOf(string);
+        if (column === -1)
+            continue;
+        lines[i] = lines[i].replace(string, replacement);
+        var lineEndings = replacement.lineEndings();
+        var lastLineLength = lineEndings[lineEndings.length - 1] - (lineEndings[lineEndings.length - 2] || 0);
+        oldRange = new WebInspector.TextRange(i, column, i, column + string.length);
+        newRange = new WebInspector.TextRange(i, column, i + lineEndings.length - 1, lastLineLength);
+        break;
+    }
+    sourceFrame.afterTextChanged(oldRange, newRange);
+    sourceFrame._textViewer._commitEditing();
+}
+
+};
Property changes on: trunk/LayoutTests/http/tests/inspector/live-edit-test.js
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/inspector/debugger/live-edit.html (90992 => 90993)


--- trunk/LayoutTests/inspector/debugger/live-edit.html	2011-07-14 12:15:56 UTC (rev 90992)
+++ trunk/LayoutTests/inspector/debugger/live-edit.html	2011-07-14 13:28:19 UTC (rev 90993)
@@ -2,6 +2,7 @@
 <head>
 <script src=""
 <script src=""
+<script src=""
 <script src=""
 <script src=""
 
@@ -111,23 +112,7 @@
     function replaceInSource(sourceFrame, string, replacement, callback)
     {
         InspectorTest.addSniffer(WebInspector.debuggerModel, "_didEditScriptSource", callback);
-        sourceFrame._textViewer._mainPanel.readOnly = false;
-        sourceFrame.beforeTextChanged();
-        var oldRange, newRange;
-        var lines = sourceFrame._textModel._lines;
-        for (var i = 0; i < lines.length; ++i) {
-            var column = lines[i].indexOf(string);
-            if (column === -1)
-                continue;
-            lines[i] = lines[i].replace(string, replacement);
-            var lineEndings = replacement.lineEndings();
-            var lastLineLength = lineEndings[lineEndings.length - 1] - (lineEndings[lineEndings.length - 2] || 0);
-            oldRange = new WebInspector.TextRange(i, column, i, column + string.length);
-            newRange = new WebInspector.TextRange(i, column, i + lineEndings.length - 1, lastLineLength);
-            break;
-        }
-        sourceFrame.afterTextChanged(oldRange, newRange);
-        sourceFrame._textViewer._commitEditing();
+        InspectorTest.replaceInSource(sourceFrame, string, replacement);
     }
 };
 

Added: trunk/LayoutTests/inspector/styles/css-live-edit-expected.txt (0 => 90993)


--- trunk/LayoutTests/inspector/styles/css-live-edit-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/css-live-edit-expected.txt	2011-07-14 13:28:19 UTC (rev 90993)
@@ -0,0 +1,14 @@
+Tests that styles are updated when live-editing css resource.
+
+
+Running: testLiveEdit
+[expanded]  ()
+display: block;
+    div - block user agent stylesheet
+font-size: 20px;
+    body - 20px get-set-stylesheet-text.css:1
+
+[expanded] element.style { ()
+
+
+
Property changes on: trunk/LayoutTests/inspector/styles/css-live-edit-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/styles/css-live-edit.html (0 => 90993)


--- trunk/LayoutTests/inspector/styles/css-live-edit.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/css-live-edit.html	2011-07-14 13:28:19 UTC (rev 90993)
@@ -0,0 +1,47 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<link rel="stylesheet" href=""
+<div id=foo></div>
+<script>
+
+function test()
+{
+    WebInspector.showPanel("resources");
+
+    InspectorTest.runTestSuite([
+        function testLiveEdit(next)
+        {
+            InspectorTest.showResource("get-set-stylesheet-text.css", didShowResource);
+
+            function didShowResource(sourceFrame)
+            {
+                InspectorTest.addSniffer(WebInspector.CSSStyleModel.prototype, "_fireStyleSheetChanged", didEditResource);
+                InspectorTest.replaceInSource(sourceFrame, "font-size: 12px;", "font-size: 20px;");
+            }
+
+            function didEditResource()
+            {
+                InspectorTest.selectNodeAndWaitForStyles("foo", didSelectElement);
+            }
+
+            function didSelectElement()
+            {
+                InspectorTest.dumpSelectedElementStyles(false, true);
+                next();
+            }
+        }
+    ]);
+};
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests that styles are updated when live-editing css resource.</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/styles/css-live-edit.html
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to