Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / extensions / extensions-resources.html
index 9b2fb39..ab1cb30 100644 (file)
@@ -25,6 +25,19 @@ InspectorTest.clickOnURL = function()
     xpathResult.singleNodeValue.dispatchEvent(click);
 }
 
+InspectorTest.waitForStyleSheetChangedEvent = function(reply)
+{
+    var oldUpdateTimeout = WebInspector.StyleFile.updateTimeout;
+    WebInspector.StyleFile.updateTimeout = 0;
+    InspectorTest.addSniffer(WebInspector.CSSStyleModel.prototype, "_fireStyleSheetChanged", onStyleSheetChanged);
+
+    function onStyleSheetChanged()
+    {
+        WebInspector.StyleFile.updateTimeout = oldUpdateTimeout;
+        reply();
+    }
+}
+
 }
 
 function extension_testGetAllResources(nextTest)
@@ -82,64 +95,40 @@ function extension_testGetResourceContent(nextTest)
     });
 }
 
-// Extensions tests override WebInspector.StyleFile.updateTimeout because otherwise extensions don't have any control over applying changes to domain specific bindings.
-function extension_setFakeStyleSheetUpdateTimeout(callback)
-{
-    evaluateOnFrontend("WebInspector.oldStyleSheetUpdateTimeout = WebInspector.StyleFile.updateTimeout; WebInspector.StyleFile.updateTimeout = -1; reply();", callback);
-}
-
-function extension_resetStyleSheetUpdateTimeout(callback)
-{
-    evaluateOnFrontend("WebInspector.StyleFile.updateTimeout = WebInspector.oldStyleSheetUpdateTimeout; delete WebInspector.oldStyleSheetUpdateTimeout; reply();", callback);
-}
-
 function extension_testSetResourceContent(nextTest)
 {
-    extension_setFakeStyleSheetUpdateTimeout(step2);
+    evaluateOnFrontend("InspectorTest.waitForStyleSheetChangedEvent(reply);", step2);
 
-    function step2()
-    {
-        extension_runWithResource(/audits-style1\.css$/, function(resource) {
-            resource.setContent("div.test { width: 126px; height: 42px; }", false, step3);
-        });
-    }
+    extension_runWithResource(/audits-style1\.css$/, function(resource) {
+        resource.setContent("div.test { width: 126px; height: 42px; }", false, function() {});
+    });
 
-    function step3()
+    function step2()
     {
         webInspector.inspectedWindow.eval("document.getElementById('test-div').clientWidth", function(result) {
             output("div.test width after stylesheet edited (should be 126): " + result);
-            step4();
+            nextTest();
         });
     }
-
-    function step4()
-    {
-        extension_resetStyleSheetUpdateTimeout(nextTest);
-    }
 }
 
 function extension_testOnContentCommitted(nextTest)
 {
     var expected_content = "div.test { width: 220px; height: 42px; }";
-    extension_setFakeStyleSheetUpdateTimeout(step2);
-
-    function step2()
-    {
 
-        webInspector.inspectedWindow.onResourceContentCommitted.addListener(onContentCommitted);
-        extension_runWithResource(/audits-style1\.css$/, function(resource) {
-            resource.setContent("div.test { width: 140px; height: 42px; }", false);
+    webInspector.inspectedWindow.onResourceContentCommitted.addListener(onContentCommitted);
+    extension_runWithResource(/audits-style1\.css$/, function(resource) {
+        resource.setContent("div.test { width: 140px; height: 42px; }", false);
+    });
+    // The next step is going to produce a console message that will be logged, so synchronize the output now.
+    evaluateOnFrontend("InspectorTest.runAfterPendingDispatches(reply)", function() {
+        extension_runWithResource(/abe\.png$/, function(resource) {
+            resource.setContent("", true);
         });
-        // The next step is going to produce a console message that will be logged, so synchronize the output now.
-        evaluateOnFrontend("InspectorTest.runAfterPendingDispatches(reply)", function() {
-            extension_runWithResource(/abe\.png$/, function(resource) {
-                resource.setContent("", true);
-            });
-            extension_runWithResource(/audits-style1\.css$/, function(resource) {
-                resource.setContent(expected_content, true);
-            });
+        extension_runWithResource(/audits-style1\.css$/, function(resource) {
+            resource.setContent(expected_content, true);
         });
-    }
+    });
 
     function onContentCommitted(resource, content)
     {
@@ -149,14 +138,9 @@ function extension_testOnContentCommitted(nextTest)
         webInspector.inspectedWindow.onResourceContentCommitted.removeListener(onContentCommitted);
         resource.getContent(function(content) {
             output("Revision content: " + content);
-            step3();
+            nextTest();
         });
     }
-
-    function step3()
-    {
-        extension_resetStyleSheetUpdateTimeout(nextTest);
-    }
 }
 
 function extension_testOnResourceAdded(nextTest)