Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / Tests.js
index 3207b82..318dc19 100644 (file)
@@ -224,6 +224,41 @@ TestSuite.prototype.addSniffer = function(receiver, methodName, override, opt_st
     };
 };
 
+/**
+ * Waits for current throttler invocations, if any.
+ * @param {!WebInspector.Throttler} throttler
+ * @param {!function} callback
+ */
+TestSuite.prototype.waitForThrottler = function(throttler, callback)
+{
+    var test = this;
+    var scheduleShouldFail = true;
+    test.addSniffer(throttler, "schedule", onSchedule);
+
+    function hasSomethingScheduled()
+    {
+        return throttler._isRunningProcess || throttler._process;
+    }
+
+    function checkState()
+    {
+        if (!hasSomethingScheduled()) {
+            scheduleShouldFail = false;
+            callback();
+            return;
+        }
+
+        test.addSniffer(throttler, "_processCompletedForTests", checkState);
+    }
+
+    function onSchedule()
+    {
+        if (scheduleShouldFail)
+            test.fail("Unexpected Throttler.schedule");
+    }
+
+    checkState();
+};
 
 // UI Tests
 
@@ -615,8 +650,9 @@ TestSuite.prototype.testDeviceMetricsOverrides = function()
         test.releaseControl();
     }
 
-    step1();
+    WebInspector.overridesSupport._deviceMetricsChangedListenerMuted = true;
     test.takeControl();
+    this.waitForThrottler(WebInspector.overridesSupport._deviceMetricsThrottler, step1);
 };
 
 TestSuite.prototype.waitForTestResultsInConsole = function()
@@ -885,7 +921,7 @@ function runTests()
         new TestSuite().runTest(name);
 }
 
-WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.InspectorUILoadedForTests, runTests);
+WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.InspectorAgentEnabledForTests, runTests);
 
 })();