Changeset 80419 in webkit


Ignore:
Timestamp:
Mar 5, 2011 3:20:27 AM (13 years ago)
Author:
loislo@chromium.org
Message:

2011-03-05 Ilya Tikhonovsky <loislo@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: introduce protocol test for ConsoleAgent.
https://bugs.webkit.org/show_bug.cgi?id=55819

  • http/tests/inspector/protocol-test.js: (initialize_ProtocolTest.InspectorTest._dumpEvent): (initialize_ProtocolTest.InspectorTest._dumpCallArguments): (initialize_ProtocolTest): (initialize_ProtocolTest.):
  • inspector/protocol/console-agent-expected.txt: Added.
  • inspector/protocol/console-agent.html: Added.
  • inspector/protocol/runtime-agent.html:
Location:
trunk/LayoutTests
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80417 r80419  
     12011-03-05  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: introduce protocol test for ConsoleAgent.
     6        https://bugs.webkit.org/show_bug.cgi?id=55819
     7
     8        * http/tests/inspector/protocol-test.js:
     9        (initialize_ProtocolTest.InspectorTest._dumpEvent):
     10        (initialize_ProtocolTest.InspectorTest._dumpCallArguments):
     11        (initialize_ProtocolTest):
     12        (initialize_ProtocolTest.):
     13        * inspector/protocol/console-agent-expected.txt: Added.
     14        * inspector/protocol/console-agent.html: Added.
     15        * inspector/protocol/runtime-agent.html:
     16
    1172011-03-05  Andrey Kosyakov  <caseq@chromium.org>
    218
  • trunk/LayoutTests/http/tests/inspector/protocol-test.js

    r80341 r80419  
    1717};
    1818
    19 InspectorTest._dumpTestResult = function(callArguments)
     19InspectorTest._dumpEvent = function()
    2020{
    21     var functionName = callArguments.shift();
    22     this.filterProps(callArguments, this._nondeterministicProps);
    23     var expression = JSON.stringify(callArguments);
    24     expression = expression.slice(1, expression.length - 1).replace(/\"<number>\"/g, "<number>");;
    25     var sentObject = JSON.parse(this._lastSentTestMessage);
    26     var receivedObject = (typeof this._lastReceivedMessage === "string") ? JSON.parse(this._lastReceivedMessage) : this._lastReceivedMessage;
     21    var args = Array.prototype.slice.call(arguments);
     22    var eventName = args.shift();
     23    InspectorTest._agentCoverage[eventName] = "checked";
     24    InspectorTest.addResult("event " + InspectorTest._agentName + "." + eventName);
     25    InspectorTest.addObject(InspectorTest._lastReceivedMessage, InspectorTest._nondeterministicProps);
     26    InspectorTest.addResult("");
     27
     28    var originalEventHandler = args.shift();
     29    originalEventHandler.apply(this, args);
     30};
     31
     32
     33InspectorTest._dumpCallArguments = function(callArguments)
     34{
     35    var callArgumentsCopy = JSON.parse(JSON.stringify(callArguments));
     36    var agentName = callArgumentsCopy.shift();
     37    var functionName = callArgumentsCopy.shift();
     38    this.filterProps(callArgumentsCopy, this._nondeterministicProps);
     39    var expression = JSON.stringify(callArgumentsCopy);
     40    expression = expression.slice(1, expression.length - 1).replace(/\"<number>\"/g, "<number>");
    2741
    2842    InspectorTest.addResult("-----------------------------------------------------------");
    29     InspectorTest.addResult(this._agentName + "." + functionName + "(" + expression + ")");
    30     InspectorTest.addResult("");
    31     InspectorTest.addResult("request:");
    32     InspectorTest.addObject(sentObject, this._nondeterministicProps);
    33     InspectorTest.addResult("");
    34     InspectorTest.addResult("response:");
    35     InspectorTest.addObject(receivedObject, this._nondeterministicProps);
     43    InspectorTest.addResult(agentName + "." + functionName + "(" + expression + ")");
    3644    InspectorTest.addResult("");
    3745};
    3846
    39 InspectorTest._callback = function(callArguments, result)
     47InspectorTest._callback = function(result)
    4048{
    41     this._dumpTestResult(callArguments);
    42     this._runNextStep(result);
     49    InspectorTest.addResult("response:");
     50    InspectorTest.addObject(InspectorTest._lastReceivedMessage, InspectorTest._nondeterministicProps);
     51    InspectorTest.addResult("");
     52    InspectorTest._runNextTest();
    4353};
    4454
    45 InspectorTest._runNextStep = function(result)
     55InspectorTest._runNextTest = function()
    4656{
    4757    var step = ++this._step;
    4858    var nextTest = this._testSuite[step];
    4959    if (nextTest) {
    50         var nextTestCopy = JSON.parse(JSON.stringify(nextTest));
    51         nextTest.push(this._callback.bind(this, nextTestCopy));
     60        InspectorTest._dumpCallArguments(nextTest);
     61
     62        nextTest.push(this._callback.bind(this));
     63
     64        var agentName = nextTest.shift();
    5265        var functionName = nextTest.shift();
    53         this._agentCoverage[functionName] = "checked";
    54         this._agent[functionName].apply(this._agent, nextTest);
    55         this._lastSentTestMessage = this._lastSentMessage;
     66        window[agentName][functionName].apply(window[agentName], nextTest);
     67
     68        var lastSentMessage = InspectorTest._lastSentMessage; // This is because the next call will override _lastSentMessage.
     69        InspectorTest.addResult("request:");
     70        InspectorTest.addObject(lastSentMessage, InspectorTest._nondeterministicProps);
     71        InspectorTest.addResult("");
     72
     73        if (agentName === this._agentName)
     74            this._agentCoverage[functionName] = "checked";
    5675    }
    5776    else {
     
    7291    for (var i = 0; i < nondeterministicProps.length; ++i)
    7392        this._nondeterministicProps[nondeterministicProps[i]] = true;
    74     this._agent = window[agentName];
     93    var agent = window[agentName];
     94
    7595    this._agentCoverage = {};
    76     for (var key in this._agent)
     96    for (var key in agent)
    7797        this._agentCoverage[key] = "not checked";
     98
     99    var domain = agentName.replace(/Agent$/,"");
     100    var domainMessagesHandler = InspectorBackend._domainDispatchers[domain];
     101    for (var eventName in domainMessagesHandler) {
     102        this._agentCoverage[eventName] = "not checked";
     103        domainMessagesHandler[eventName] = InspectorTest._dumpEvent.bind(domainMessagesHandler, eventName, domainMessagesHandler[eventName]);
     104    }
     105
     106    this._originalDispatch = InspectorBackend.dispatch;
     107    InspectorBackend.dispatch = function(message)
     108    {
     109        InspectorTest._lastReceivedMessage = (typeof message === "string") ? JSON.parse(message) : message;
     110        InspectorTest._originalDispatch.apply(InspectorBackend, [message]);
     111    }
     112
     113    this._originalSendMessageToBackend = InspectorFrontendHost.sendMessageToBackend;
     114    InspectorFrontendHost.sendMessageToBackend = function(message)
     115    {
     116        InspectorTest._lastSentMessage = JSON.parse(message);
     117        InspectorTest._originalSendMessageToBackend.apply(InspectorFrontendHost, [message]);
     118    }
     119
    78120    this._step = -1;
    79121
    80     this._originalDispatch = InspectorBackend.dispatch;
    81     InspectorBackend.dispatch = function(message) { InspectorTest._lastReceivedMessage = message; InspectorTest._originalDispatch.apply(InspectorBackend, [message]); }
    82 
    83     this._originalSendMessageToBackend = InspectorFrontendHost.sendMessageToBackend;
    84     InspectorFrontendHost.sendMessageToBackend = function(message) { InspectorTest._lastSentMessage = message; InspectorTest._originalSendMessageToBackend.apply(InspectorFrontendHost, [message]); }
    85 
    86     this._runNextStep();
     122    this._runNextTest();
    87123};
    88124
  • trunk/LayoutTests/inspector/protocol/runtime-agent.html

    r80349 r80419  
    1818    {
    1919        var testSuite = [
    20             ["evaluate", 'testObject', 'test', false],
    21             ["evaluateOn", result.objectId, 'this.assignedByEvaluateOn = "evaluateOn function works fine";'],
    22             ["setPropertyValue", result.objectId, 'assignedBySetPropertyValue', 'true'],
    23             ["setPropertyValue", result.objectId, 'removedBySetPropertyValue', ''],
    24             ["getProperties", result.objectId, false, false],
    25             ["releaseObject", result.objectId],
    26             ["releaseObjectGroup", result.objectId.injectedScriptId, 'test']];
     20            ["RuntimeAgent", "evaluate", 'testObject', 'test', false],
     21            ["RuntimeAgent", "evaluateOn", result.objectId, 'this.assignedByEvaluateOn = "evaluateOn function works fine";'],
     22            ["RuntimeAgent", "setPropertyValue", result.objectId, 'assignedBySetPropertyValue', 'true'],
     23            ["RuntimeAgent", "setPropertyValue", result.objectId, 'removedBySetPropertyValue', ''],
     24            ["RuntimeAgent", "getProperties", result.objectId, false, false],
     25            ["RuntimeAgent", "releaseObject", result.objectId],
     26            ["RuntimeAgent", "releaseObjectGroup", result.objectId.injectedScriptId, 'test']];
    2727
    2828        InspectorTest.runProtocolTestSuite("RuntimeAgent", testSuite, ['seq', 'id', 'injectedScriptId']);
Note: See TracChangeset for help on using the changeset viewer.