Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / inspector-test.js
index 1b6ee27..5a23464 100644 (file)
@@ -115,7 +115,7 @@ InspectorTest.didInvokePageFunctionAsync = function(callId, value)
 {
     var callback = pendingEvalRequests[callId];
     if (!callback) {
-        InspectorTest.addResult("Missing callback for ascyn eval " + callId + ", perhaps callback invoked twice?");
+        InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?");
         return;
     }
     delete pendingEvalRequests[callId];
@@ -240,6 +240,13 @@ InspectorTest.assertGreaterOrEqual = function(a, b, message)
         InspectorTest.addResult("FAILED: " + (message ? message + ": " : "") + a + " < " + b);
 }
 
+InspectorTest.registerModule = function(moduleName, loadImmediately)
+{
+    runtime._registerModule(moduleName);
+    if (loadImmediately)
+        runtime.loadModule(moduleName);
+}
+
 InspectorTest.navigate = function(url, callback)
 {
     InspectorTest._pageLoadedCallback = InspectorTest.safeWrap(callback);
@@ -559,7 +566,7 @@ InspectorTest.TempFileMock.prototype = {
 InspectorTest.dumpLoadedModules = function(next)
 {
     InspectorTest.addResult("Loaded modules:");
-    var modules = WebInspector.moduleManager._modules;
+    var modules = self.runtime._modules;
     for (var i = 0; i < modules.length; ++i) {
         if (modules[i]._loaded) {
             InspectorTest.addResult("    " + modules[i]._descriptor.name);
@@ -607,7 +614,23 @@ InspectorTest.TimeoutMock.prototype = {
 
 WebInspector.TempFile = InspectorTest.TempFileMock;
 
-};
+WebInspector.targetManager.observeTargets({
+    targetAdded: function(target)
+    {
+        if (!WebInspector.domModel)
+            WebInspector.domModel = target.domModel;
+        if (!WebInspector.consoleModel)
+            WebInspector.consoleModel = target.consoleModel;
+        if (!WebInspector.networkManager)
+            WebInspector.networkManager = target.networkManager;
+        if (!WebInspector.timelineManager)
+            WebInspector.timelineManager = target.timelineManager;
+    },
+
+    targetRemoved: function(target) { }
+});
+
+};  // initialize_InspectorTest
 
 var initializeCallId = 0;
 var runTestCallId = 1;
@@ -748,23 +771,28 @@ function closeInspectorAndNotifyDone()
 
 var outputElement;
 var outputElementParent;
+var savedOutput;
 
-function output(text)
+function createOutputElement()
 {
-    if (!outputElement) {
-        var intermediate = document.createElement("div");
-        document.body.appendChild(intermediate);
+    var intermediate = document.createElement("div");
+    document.body.appendChild(intermediate);
 
-        outputElementParent = document.createElement("div");
-        intermediate.appendChild(outputElementParent);
+    outputElementParent = document.createElement("div");
+    intermediate.appendChild(outputElementParent);
 
-        outputElement = document.createElement("div");
-        outputElement.className = "output";
-        outputElement.id = "output";
-        outputElement.style.whiteSpace = "pre";
-        if (!window.quietUntilDone)
-            outputElementParent.appendChild(outputElement);
-    }
+    outputElement = document.createElement("div");
+    outputElement.className = "output";
+    outputElement.id = "output";
+    outputElement.style.whiteSpace = "pre";
+    if (!window.quietUntilDone)
+        outputElementParent.appendChild(outputElement);
+}
+
+function output(text)
+{
+    if (!outputElement)
+        createOutputElement();
     outputElement.appendChild(document.createTextNode(text));
     outputElement.appendChild(document.createElement("br"));
 }
@@ -777,6 +805,19 @@ function clearOutput()
     }
 }
 
+function saveOutput()
+{
+    savedOutput = outputElement ? outputElement.innerHTML : "";
+}
+
+function restoreOutput()
+{
+    if (!savedOutput)
+        return;
+    createOutputElement();
+    outputElement.innerHTML = savedOutput;
+}
+
 function StandaloneTestRunnerStub()
 {
 }