Web Inspector: Expand Console domain test coverage
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 19:53:59 +0000 (19:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 19:53:59 +0000 (19:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148740

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-09-04
Reviewed by Brian Burg.

Source/JavaScriptCore:

* inspector/protocol/Console.json:
Update the description of this command now that it only
manipulates $0, and not $1, $2, .. $n.

Source/WebInspectorUI:

* UserInterface/Protocol/RemoteObject.js:
Add a few helpers for checking the RemoteObject type.

LayoutTests:

Test more Console domain commands and events.

* inspector/console/addInspectedNode-expected.txt: Added.
* inspector/console/addInspectedNode.html: Added.
* inspector/console/clearMessages-expected.txt: Added.
* inspector/console/clearMessages.html: Added.
* inspector/console/messageRepeatCountUpdated-expected.txt: Added.
* inspector/console/messageRepeatCountUpdated.html: Added.
* inspector/console/messagesCleared-expected.txt: Added.
* inspector/console/messagesCleared.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189373 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/console/addInspectedNode-expected.txt [new file with mode: 0644]
LayoutTests/inspector/console/addInspectedNode.html [new file with mode: 0644]
LayoutTests/inspector/console/clearMessages-expected.txt [new file with mode: 0644]
LayoutTests/inspector/console/clearMessages.html [new file with mode: 0644]
LayoutTests/inspector/console/messageRepeatCountUpdated-expected.txt [new file with mode: 0644]
LayoutTests/inspector/console/messageRepeatCountUpdated.html [new file with mode: 0644]
LayoutTests/inspector/console/messagesCleared-expected.txt [new file with mode: 0644]
LayoutTests/inspector/console/messagesCleared.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Console.json
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js

index 8e4c2c8..363193d 100644 (file)
@@ -1,3 +1,21 @@
+2015-09-04  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Expand Console domain test coverage
+        https://bugs.webkit.org/show_bug.cgi?id=148740
+
+        Reviewed by Brian Burg.
+
+        Test more Console domain commands and events.
+
+        * inspector/console/addInspectedNode-expected.txt: Added.
+        * inspector/console/addInspectedNode.html: Added.
+        * inspector/console/clearMessages-expected.txt: Added.
+        * inspector/console/clearMessages.html: Added.
+        * inspector/console/messageRepeatCountUpdated-expected.txt: Added.
+        * inspector/console/messageRepeatCountUpdated.html: Added.
+        * inspector/console/messagesCleared-expected.txt: Added.
+        * inspector/console/messagesCleared.html: Added.
+
 2015-09-04  Jer Noble  <jer.noble@apple.com>
 
         Unreviewed gardening; enabling media/ and http/tests/media/ tests (with expected failures) on ios-simulator
diff --git a/LayoutTests/inspector/console/addInspectedNode-expected.txt b/LayoutTests/inspector/console/addInspectedNode-expected.txt
new file mode 100644 (file)
index 0000000..672ab49
--- /dev/null
@@ -0,0 +1,21 @@
+Test for the Console.addInspectedNode command.
+
+
+== Running test suite: Console.addInspectedNode
+-- Running test case: Check$0IsUndefined
+PASS: $0 should be undefined.
+
+-- Running test case: SetAndCheckNodeA
+PASS: $0 should be a node.
+PASS: $0 should be Node A.
+
+-- Running test case: SetBadNodeId
+PASS: Should be an error
+PASS: $0 should be a node.
+PASS: $0 should be Node A.
+
+-- Running test case: SetAndCheckNodeB
+PASS: $0 should be a node.
+PASS: $0 should not be Node A.
+PASS: $0 should be Node B.
+
diff --git a/LayoutTests/inspector/console/addInspectedNode.html b/LayoutTests/inspector/console/addInspectedNode.html
new file mode 100644 (file)
index 0000000..3efb527
--- /dev/null
@@ -0,0 +1,104 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    function evaluate$0(callback) {
+        const objectGroup = "test";
+        const includeCommandLineAPI = true;
+        const ignorePauseOnExceptionsAndMute = false;
+        const shouldReturnByValue = false;
+        const shouldGeneratePreview = false;
+        const shouldSaveResult = false;
+        WebInspector.runtimeManager.evaluateInInspectedWindow("$0", objectGroup, includeCommandLineAPI, ignorePauseOnExceptionsAndMute, shouldReturnByValue, shouldGeneratePreview, shouldSaveResult, callback);
+    }
+
+    let nodeA, nodeB;
+
+    let suite = InspectorTest.createAsyncSuite("Console.addInspectedNode");
+
+    suite.addTestCase({
+        name: "Check$0IsUndefined",
+        description: "No inspected node yet, $0 should be undefined.",
+        test: (resolve, reject) => {
+            evaluate$0((remoteObject) => {
+                InspectorTest.expectThat(remoteObject.isUndefined(), "$0 should be undefined.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "SetAndCheckNodeA",
+        description: "Set the inspected node to be Node A and check that $0 is Node A.",
+        test: (resolve, reject) => {
+            ConsoleAgent.addInspectedNode(nodeA.id);
+            evaluate$0((remoteObject) => {
+                remoteObject.pushNodeToFrontend((nodeId) => {
+                    InspectorTest.expectThat(remoteObject.isNode(), "$0 should be a node.");
+                    InspectorTest.expectThat(nodeId === nodeA.id, "$0 should be Node A.");
+                    resolve();
+                });
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "SetBadNodeId",
+        description: "If an invalid inspected node is set, it should not be bound to $0.",
+        test: (resolve, reject) => {
+            ConsoleAgent.addInspectedNode(999999, (error) => {
+                InspectorTest.expectThat(error, "Should be an error");
+            });
+            evaluate$0((remoteObject) => {
+                remoteObject.pushNodeToFrontend((nodeId) => {
+                    InspectorTest.expectThat(remoteObject.isNode(), "$0 should be a node.");
+                    InspectorTest.expectThat(nodeId === nodeA.id, "$0 should be Node A.");
+                    resolve();
+                });
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "SetAndCheckNodeB",
+        description: "Set the inspected node to be Node B and check that $0 is Node B.",
+        test: (resolve, reject) => {
+            ConsoleAgent.addInspectedNode(nodeB.id);
+            evaluate$0((remoteObject) => {
+                remoteObject.pushNodeToFrontend((nodeId) => {
+                    InspectorTest.expectThat(remoteObject.isNode(), "$0 should be a node.");
+                    InspectorTest.expectThat(nodeId !== nodeA.id, "$0 should not be Node A.");
+                    InspectorTest.expectThat(nodeId === nodeB.id, "$0 should be Node B.");
+                    resolve();
+                });
+            });
+        }
+    });
+
+    // FIXME: What should $0 be after reloading / navigating the page. Should it be cleared?
+
+    WebInspector.domTreeManager.requestDocument((documentNode) => {
+        WebInspector.domTreeManager.querySelector(documentNode.id, "#a", (contentNodeId) => {
+            InspectorTest.assert(contentNodeId, "#a node should exist.");
+            nodeA = WebInspector.domTreeManager.nodeForId(contentNodeId);
+        });
+        WebInspector.domTreeManager.querySelector(documentNode.id, "#b", (contentNodeId) => {
+            InspectorTest.assert(contentNodeId, "#b node should exist.");
+            nodeB = WebInspector.domTreeManager.nodeForId(contentNodeId);
+            suite.runTestCasesAndFinish();
+        });
+    });
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Test for the Console.addInspectedNode command.</p>
+<div style="display:none">
+    <p id="a">Node A</p>
+    <p id="b">Node B</p>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/inspector/console/clearMessages-expected.txt b/LayoutTests/inspector/console/clearMessages-expected.txt
new file mode 100644 (file)
index 0000000..967f8a5
--- /dev/null
@@ -0,0 +1,7 @@
+Test for the Console.clearMessages command.
+
+
+== Running test suite: Console.clearMessages
+-- Running test case: CallClearMessages
+PASS: Cleared event should fire.
+
diff --git a/LayoutTests/inspector/console/clearMessages.html b/LayoutTests/inspector/console/clearMessages.html
new file mode 100644 (file)
index 0000000..bebd892
--- /dev/null
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Console.clearMessages");
+
+    suite.addTestCase({
+        name: "CallClearMessages",
+        description: "Calling the Console.clearMessages command should trigger Console.messagesCleared.",
+        test: (resolve, reject) => {
+            ConsoleAgent.clearMessages();
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                InspectorTest.assert(false, "MessageAdded event should not fire.");
+                reject();
+            });
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.Cleared, (event) => {
+                InspectorTest.expectThat(event, "Cleared event should fire.");
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Test for the Console.clearMessages command.</p>
+</body>
+</html>
diff --git a/LayoutTests/inspector/console/messageRepeatCountUpdated-expected.txt b/LayoutTests/inspector/console/messageRepeatCountUpdated-expected.txt
new file mode 100644 (file)
index 0000000..0d0a2b4
--- /dev/null
@@ -0,0 +1,66 @@
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: different message
+CONSOLE MESSAGE: line 1: different message
+CONSOLE MESSAGE: line 1: test message
+CONSOLE MESSAGE: line 1: equal parameter values
+CONSOLE MESSAGE: line 1: equal parameter values
+CONSOLE MESSAGE: line 1: object
+CONSOLE MESSAGE: line 1: object
+CONSOLE MESSAGE: line 1: level
+CONSOLE MESSAGE: line 1: level
+Test for the Console.messageRepeatCountUpdated event.
+
+
+== Running test suite: Console.messageRepeatCountUpdated
+-- Running test case: AddTestMessage
+PASS: MessageAdded event should fire.
+PASS: ConsoleMessage repeatCount is 1.
+
+-- Running test case: RepeatTestMessage1
+PASS: PreviousMessageRepeatCountUpdated should fire.
+PASS: Count should be 2.
+
+-- Running test case: RepeatTestMessage2
+PASS: PreviousMessageRepeatCountUpdated should fire.
+PASS: Count should be 3.
+
+-- Running test case: RepeatTestMessage3
+PASS: PreviousMessageRepeatCountUpdated should fire.
+PASS: Count should be 4.
+
+-- Running test case: RepeatTestMessage4
+PASS: PreviousMessageRepeatCountUpdated should fire.
+PASS: Count should be 5.
+
+-- Running test case: RepeatTestMessage5
+PASS: PreviousMessageRepeatCountUpdated should fire.
+PASS: Count should be 6.
+
+-- Running test case: AddDifferentMessage
+PASS: MessageAdded event should fire.
+PASS: ConsoleMessage repeatCount is 1.
+
+-- Running test case: RepeatDifferentMessage
+PASS: PreviousMessageRepeatCountUpdated should fire.
+PASS: Count should be 2.
+
+-- Running test case: AddTestMessageAgain
+PASS: MessageAdded event should fire.
+PASS: ConsoleMessage repeatCount is 1.
+
+-- Running test case: MessagesWithEqualValuesRepeats
+PASS: PreviousMessageRepeatCountUpdated should fire for repeat messages with equal values.
+
+-- Running test case: MessagesWithObjectsDoNotRepeat
+PASS: MessageAdded event should fire.
+PASS: MessageAdded event should fire.
+
+-- Running test case: MessagesWithDifferentLevelsDoNotRepeat
+PASS: MessageAdded event should fire.
+PASS: MessageAdded event should fire.
+
diff --git a/LayoutTests/inspector/console/messageRepeatCountUpdated.html b/LayoutTests/inspector/console/messageRepeatCountUpdated.html
new file mode 100644 (file)
index 0000000..6e802f2
--- /dev/null
@@ -0,0 +1,190 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    const testMessage = "console.log('test message')";
+    const differentMessage = "console.log('different message')";
+
+    let suite = InspectorTest.createAsyncSuite("Console.messageRepeatCountUpdated");
+
+    suite.addTestCase({
+        name: "AddTestMessage",
+        description: "Add a new message, it should have a single repeat count.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage(testMessage);
+
+            let listener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.assert(false, "Should not fire PreviousMessageRepeatCountUpdated yet.");
+                reject();
+            });
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                InspectorTest.expectThat(event.data.message instanceof WebInspector.ConsoleMessage, "MessageAdded event should fire.");
+                InspectorTest.expectThat(event.data.message.repeatCount === 1, "ConsoleMessage repeatCount is 1.");
+                WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, listener, null);
+                resolve();
+            });
+        }
+    });
+
+    for (let i = 1; i <= 5; ++i) {
+        suite.addTestCase({
+            name: `RepeatTestMessage${i}`,
+            description: "Repeat the last message, it should trigger messageRepeatCountUpdated.",
+            test: (resolve, reject) => {
+                InspectorTest.evaluateInPage(testMessage);
+
+                let listener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                    InspectorTest.assert(false, "Should not fire MessageAdded, this should be a repeat.");
+                    reject();
+                });
+
+                WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                    InspectorTest.expectThat(event, "PreviousMessageRepeatCountUpdated should fire.");
+                    InspectorTest.expectThat(event.data.count === (i + 1), `Count should be ${i + 1}.`);
+                    WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, listener, null);
+                    resolve();
+                });
+            }
+        });
+    }
+
+    suite.addTestCase({
+        name: "AddDifferentMessage",
+        description: "Add a different message, it should reset the repeat count.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage(differentMessage);
+
+            let listener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.assert(false, "Should not fire PreviousMessageRepeatCountUpdated, this message is different.");
+                reject();
+            });
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                InspectorTest.expectThat(event.data.message instanceof WebInspector.ConsoleMessage, "MessageAdded event should fire.");
+                InspectorTest.expectThat(event.data.message.repeatCount === 1, "ConsoleMessage repeatCount is 1.");
+                WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, listener, null);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "RepeatDifferentMessage",
+        description: "Repeat this different message, it should increment the repeat count.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage(differentMessage);
+
+            let listener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                InspectorTest.assert(false, "Should not fire MessageAdded, this should be a repeat.");
+                reject();
+            });
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.expectThat(event, "PreviousMessageRepeatCountUpdated should fire.");
+                InspectorTest.expectThat(event.data.count === 2, "Count should be 2.");
+                WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, listener, null);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "AddTestMessageAgain",
+        description: "Add the original message again, it should have a single repeat count.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage(testMessage);
+
+            let listener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.assert(false, "Should not fire PreviousMessageRepeatCountUpdated yet.");
+                reject();
+            });
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                InspectorTest.expectThat(event.data.message instanceof WebInspector.ConsoleMessage, "MessageAdded event should fire.");
+                InspectorTest.expectThat(event.data.message.repeatCount === 1, "ConsoleMessage repeatCount is 1.");
+                WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, listener, null);
+                resolve();
+            });
+        }
+    });
+
+    // --------
+
+    suite.addTestCase({
+        name: "MessagesWithEqualValuesRepeats",
+        description: "Repeat messages with equal values should trigger messageRepeatCountUpdated.",
+        test: (resolve, reject) => {
+            const messageWithValues = "console.log('equal parameter values', 1, 2)";
+            InspectorTest.evaluateInPage(messageWithValues);
+            InspectorTest.evaluateInPage(messageWithValues);
+
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.expectThat(event, "PreviousMessageRepeatCountUpdated should fire for repeat messages with equal values.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "MessagesWithObjectsDoNotRepeat",
+        description: "Repeat messages with objects should not trigger messageRepeatCountUpdated.",
+        test: (resolve, reject) => {
+            const messageWithObject = "console.log('object', window)";
+            InspectorTest.evaluateInPage(messageWithObject);
+            InspectorTest.evaluateInPage(messageWithObject);
+
+            let repeatListener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.assert(false, "PreviousMessageRepeatCountUpdated should not fire for repeat messages with object arguments.");
+                reject();
+            });
+
+            let remaining = 2;
+            WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, function addListener(event) {
+                InspectorTest.expectThat(event.data.message instanceof WebInspector.ConsoleMessage, "MessageAdded event should fire.");
+                remaining--;
+                if (!remaining) {
+                    WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, repeatListener, null);
+                    WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, addListener, null);
+                    resolve();
+                }                
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "MessagesWithDifferentLevelsDoNotRepeat",
+        description: "Repeat messages with different levels should not trigger messageRepeatCountUpdated.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("console.warn('level')");
+            InspectorTest.evaluateInPage("console.error('level')");
+
+            let repeatListener = WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, (event) => {
+                InspectorTest.assert(false, "PreviousMessageRepeatCountUpdated should not fire for repeat messages with different levels.");
+                reject();
+            });
+
+            let remaining = 2;
+            WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, function addListener(event) {
+                InspectorTest.expectThat(event.data.message instanceof WebInspector.ConsoleMessage, "MessageAdded event should fire.");
+                remaining--;
+                if (!remaining) {
+                    WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.PreviousMessageRepeatCountUpdated, repeatListener, null);
+                    WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, addListener, null);
+                    resolve();
+                }                
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Test for the Console.messageRepeatCountUpdated event.</p>
+</body>
+</html>
diff --git a/LayoutTests/inspector/console/messagesCleared-expected.txt b/LayoutTests/inspector/console/messagesCleared-expected.txt
new file mode 100644 (file)
index 0000000..d610cb5
--- /dev/null
@@ -0,0 +1,16 @@
+Test for the Console.messagesCleared event.
+
+
+== Running test suite: Console.messagesCleared
+-- Running test case: ClearViaConsoleClearMessagesAPI
+PASS: Cleared event should fire.
+
+-- Running test case: ClearViaConsoleAPI
+PASS: Cleared event should fire.
+
+-- Running test case: ClearViaCommandLineAPI
+PASS: Cleared event should fire.
+
+-- Running test case: ClearViaPageReload
+PASS: Cleared event should fire.
+
diff --git a/LayoutTests/inspector/console/messagesCleared.html b/LayoutTests/inspector/console/messagesCleared.html
new file mode 100644 (file)
index 0000000..c5857e9
--- /dev/null
@@ -0,0 +1,71 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Console.messagesCleared");
+
+    suite.addTestCase({
+        name: "ClearViaConsoleClearMessagesAPI",
+        description: "Calling Console.clearMessages should trigger Console.messagesCleared.",
+        test: (resolve, reject) => {
+            ConsoleAgent.clearMessages();
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.Cleared, (event) => {
+                InspectorTest.expectThat(event, "Cleared event should fire.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "ClearViaConsoleAPI",
+        description: "Calling console.clear() should trigger Console.messagesCleared.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("console.clear()");
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.Cleared, (event) => {
+                InspectorTest.expectThat(event, "Cleared event should fire.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "ClearViaCommandLineAPI",
+        description: "Calling `clear()` in the command line API should trigger Console.messagesCleared.",
+        test: (resolve, reject) => {
+            const objectGroup = "test";
+            const includeCommandLineAPI = true;
+            const ignorePauseOnExceptionsAndMute = false;
+            const shouldReturnByValue = false;
+            const shouldGeneratePreview = false;
+            const shouldSaveResult = false;
+            WebInspector.runtimeManager.evaluateInInspectedWindow("clear()", objectGroup, includeCommandLineAPI, ignorePauseOnExceptionsAndMute, shouldReturnByValue, shouldGeneratePreview, shouldSaveResult, function(){});
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.Cleared, (event) => {
+                InspectorTest.expectThat(event, "Cleared event should fire.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "ClearViaPageReload",
+        description: "Reloading the page should trigger Console.messagesCleared.",
+        test: (resolve, reject) => {
+            InspectorTest.reloadPage();
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.Cleared, (event) => {
+                InspectorTest.expectThat(event, "Cleared event should fire.");
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Test for the Console.messagesCleared event.</p>
+</body>
+</html>
index dd975df..623b6c5 100644 (file)
@@ -1,5 +1,16 @@
 2015-09-04  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Expand Console domain test coverage
+        https://bugs.webkit.org/show_bug.cgi?id=148740
+
+        Reviewed by Brian Burg.
+
+        * inspector/protocol/Console.json:
+        Update the description of this command now that it only
+        manipulates $0, and not $1, $2, .. $n.
+
+2015-09-04  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Test RuntimeAgent.parse, detecting if a script parse error is recoverable
         https://bugs.webkit.org/show_bug.cgi?id=148790
 
index 5b319d9..a255362 100644 (file)
@@ -61,9 +61,9 @@
         {
             "name": "addInspectedNode",
             "parameters": [
-                { "name": "nodeId", "$ref": "DOM.NodeId", "description": "DOM node id to be accessible by means of $x command line API." }
+                { "name": "nodeId", "$ref": "DOM.NodeId", "description": "DOM node id to be accessible by means of $0 command line API." }
             ],
-            "description": "Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions)."
+            "description": "Enables console to refer to the node with given id via $0 (see Command Line API for more details)."
         }
     ],
     "events": [
index 269fa38..e70f11b 100644 (file)
@@ -1,3 +1,13 @@
+2015-09-04  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Expand Console domain test coverage
+        https://bugs.webkit.org/show_bug.cgi?id=148740
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Protocol/RemoteObject.js:
+        Add a few helpers for checking the RemoteObject type.
+
 2015-09-02  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r189241.
index ed2f72a..483ef5b 100644 (file)
@@ -345,6 +345,16 @@ WebInspector.RemoteObject = class RemoteObject
         }
     }
 
+    isUndefined()
+    {
+        return this._type === "undefined";
+    }
+
+    isNode()
+    {
+        return this._subtype === "node";
+    }
+
     isArray()
     {
         return this._subtype === "array";