Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / inspector-test.js
index 4c687ea..badd7ee 100644 (file)
@@ -36,12 +36,6 @@ InspectorTest.Output = {   // override in window.initialize_yourName
     }
 };
 
-InspectorTest.toViewMessage = function(message)
-{
-    WebInspector.inspectorView.panel("console");
-    return WebInspector.ConsolePanel._view()._messageToViewMessage.get(message);
-}
-
 InspectorTest.completeTest = function()
 {
     InspectorTest.Output.testComplete();
@@ -54,13 +48,13 @@ InspectorTest.evaluateInConsole = function(code, callback)
     WebInspector.inspectorView.panel("console");
     var consoleView = WebInspector.ConsolePanel._view();
     consoleView.visible = true;
-    consoleView.prompt.text = code;
+    consoleView._prompt.text = code;
     var event = document.createEvent("KeyboardEvent");
     event.initKeyboardEvent("keydown", true, true, null, "Enter", "");
-    consoleView.prompt.proxyElement.dispatchEvent(event);
+    consoleView._prompt.proxyElement.dispatchEvent(event);
     InspectorTest.addConsoleSniffer(
         function(commandResult) {
-            callback(InspectorTest.toViewMessage(commandResult).toMessageElement().textContent);
+            callback(commandResult.toMessageElement().textContent);
         });
 }
 
@@ -83,7 +77,7 @@ InspectorTest.evaluateInPage = function(code, callback)
     function mycallback(error, result, wasThrown)
     {
         if (!error)
-            callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
+            callback(WebInspector.runtimeModel.createRemoteObject(result), wasThrown);
     }
     RuntimeAgent.evaluate(code, "console", false, mycallback);
 }
@@ -93,6 +87,35 @@ InspectorTest.evaluateInPageWithTimeout = function(code)
     InspectorTest.evaluateInPage("setTimeout(unescape('" + escape(code) + "'))");
 }
 
+var lastEvalId = 0;
+var pendingEvalRequests = {};
+
+InspectorTest.invokePageFunctionAsync = function(functionName, callback)
+{
+    var id = ++lastEvalId;
+    pendingEvalRequests[id] = InspectorTest.safeWrap(callback);
+    var asyncEvalWrapper = function(callId, functionName)
+    {
+        function evalCallback(result)
+        {
+            testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest.didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");");
+        }
+        eval(functionName + "(" + evalCallback + ")");
+    }
+    InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "'))");
+}
+
+InspectorTest.didInvokePageFunctionAsync = function(callId, value)
+{
+    var callback = pendingEvalRequests[callId];
+    if (!callback) {
+        InspectorTest.addResult("Missing callback for ascyn eval " + callId + ", perhaps callback invoked twice?");
+        return;
+    }
+    delete pendingEvalRequests[callId];
+    callback(value);
+}
+
 InspectorTest.check = function(passCondition, failureText)
 {
     if (!passCondition)
@@ -120,15 +143,12 @@ InspectorTest.addResults = function(textArray)
         InspectorTest.addResult(textArray[i]);
 }
 
-function onError(event)
+window.onerror = function (message, filename, lineno, colno, error)
 {
-    window.removeEventListener("error", onError);
-    InspectorTest.addResult("Uncaught exception in inspector front-end: " + event.message + " [" + event.filename + ":" + event.lineno + "]");
+    InspectorTest.addResult("Uncaught exception in inspector front-end: " + message + " [" + error.stack + "]");
     InspectorTest.completeTest();
 }
 
-window.addEventListener("error", onError);
-
 InspectorTest.formatters = {};
 
 InspectorTest.formatters.formatAsTypeName = function(value)
@@ -367,8 +387,7 @@ InspectorTest.addSniffer = function(receiver, methodName, override, opt_sticky)
 InspectorTest.addConsoleSniffer = function(override, opt_sticky)
 {
     var sniffer = function (viewMessage) {
-        var message = viewMessage.consoleMessage();
-        override(message);
+        override(viewMessage);
     };
 
     WebInspector.inspectorView.panel("console");
@@ -551,6 +570,7 @@ WebInspector.TempFile = InspectorTest.TempFileMock;
 var initializeCallId = 0;
 var runTestCallId = 1;
 var completeTestCallId = 2;
+var evalCallbackCallId = 3;
 var frontendReopeningCount = 0;
 
 function reopenFrontend()