Title: [234635] trunk/LayoutTests
Revision
234635
Author
mattba...@apple.com
Date
2018-08-06 16:53:33 -0700 (Mon, 06 Aug 2018)

Log Message

Web Inspector: split-up async stack trace test suite to improve clarity and maintainability
https://bugs.webkit.org/show_bug.cgi?id=185398
<rdar://problem/40040289>

Reviewed by Joseph Pecoraro.

* inspector/debugger/async-stack-trace-basic-expected.txt: Added.
* inspector/debugger/async-stack-trace-basic.html: Added.
Basic tests that check for the existence of an asynchronous stack trace
when pausing inside an asynchronous callback function.

* inspector/debugger/async-stack-trace-event-listener-expected.txt: Added.
* inspector/debugger/async-stack-trace-event-listener.html: Added.
* inspector/debugger/async-stack-trace-expected.txt: Removed.

* inspector/debugger/async-stack-trace-truncate-expected.txt: Added.
* inspector/debugger/async-stack-trace-truncate.html: Added.
Test scenarios where the number of call frames in the async stack trace
exceeds the maximum depth and is truncated.

* inspector/debugger/async-stack-trace.html: Removed.

* inspector/debugger/resources/async-stack-trace-test.js: Added.
(TestPage.registerInitializer.window.getAsyncStackTrace):
(TestPage.registerInitializer.logCallFrame):
(TestPage.registerInitializer.window.logAsyncStackTrace):
(TestPage.registerInitializer.window.addAsyncStackTraceTestCase):
(TestPage.registerInitializer):
Utility functions used across tests.

* inspector/debugger/resources/postMessage-echo.html: Removed.
This was unnecessary. To check that an async stack trace exists when
pausing in a postMessage handler, all we need is an iframe that posts a
message to its parent as soon as it is created. The iframe is now created
inline in async-stack-trace-basic.html.

* platform/mac/TestExpectations:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234634 => 234635)


--- trunk/LayoutTests/ChangeLog	2018-08-06 23:49:09 UTC (rev 234634)
+++ trunk/LayoutTests/ChangeLog	2018-08-06 23:53:33 UTC (rev 234635)
@@ -1,3 +1,43 @@
+2018-08-06  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: split-up async stack trace test suite to improve clarity and maintainability
+        https://bugs.webkit.org/show_bug.cgi?id=185398
+        <rdar://problem/40040289>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/debugger/async-stack-trace-basic-expected.txt: Added.
+        * inspector/debugger/async-stack-trace-basic.html: Added.
+        Basic tests that check for the existence of an asynchronous stack trace
+        when pausing inside an asynchronous callback function.
+
+        * inspector/debugger/async-stack-trace-event-listener-expected.txt: Added.
+        * inspector/debugger/async-stack-trace-event-listener.html: Added.
+        * inspector/debugger/async-stack-trace-expected.txt: Removed.
+
+        * inspector/debugger/async-stack-trace-truncate-expected.txt: Added.
+        * inspector/debugger/async-stack-trace-truncate.html: Added.
+        Test scenarios where the number of call frames in the async stack trace
+        exceeds the maximum depth and is truncated.
+
+        * inspector/debugger/async-stack-trace.html: Removed.
+
+        * inspector/debugger/resources/async-stack-trace-test.js: Added.
+        (TestPage.registerInitializer.window.getAsyncStackTrace):
+        (TestPage.registerInitializer.logCallFrame):
+        (TestPage.registerInitializer.window.logAsyncStackTrace):
+        (TestPage.registerInitializer.window.addAsyncStackTraceTestCase):
+        (TestPage.registerInitializer):
+        Utility functions used across tests.
+
+        * inspector/debugger/resources/postMessage-echo.html: Removed.
+        This was unnecessary. To check that an async stack trace exists when
+        pausing in a postMessage handler, all we need is an iframe that posts a
+        message to its parent as soon as it is created. The iframe is now created
+        inline in async-stack-trace-basic.html.
+
+        * platform/mac/TestExpectations:
+
 2018-08-06  Daniel Bates  <daba...@apple.com>
 
         Setting table layout to fixed causes incorrect cell width calculations

Added: trunk/LayoutTests/inspector/debugger/async-stack-trace-basic-expected.txt (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-basic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-basic-expected.txt	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,83 @@
+Tests for checking that async stack traces exist when pausing in asynchronous callbacks: requestAnimationFrame, setTimeout, setInterval, and postMessage.
+
+
+== Running test suite: AsyncStackTrace.Basic
+-- Running test case: AsyncStackTrace.Basic.RequestAnimationFrame
+PAUSED
+CALL STACK:
+0: [F] handleAnimationFrame
+ASYNC CALL STACK:
+1: --- requestAnimationFrame ---
+2: [F] triggerRequestAnimationFrame
+3: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.NestedRequestAnimationFrame
+PAUSED
+CALL STACK:
+0: [F] handleAnimationFrame2
+ASYNC CALL STACK:
+1: --- requestAnimationFrame ---
+2: [F] handleAnimationFrame1
+3: --- requestAnimationFrame ---
+4: [F] triggerNestedRequestAnimationFrame
+5: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.SetTimeout
+PAUSED
+CALL STACK:
+0: [F] handleTimeout
+ASYNC CALL STACK:
+1: --- setTimeout ---
+2: [F] triggerSetTimeout
+3: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.NestedSetTimeout
+PAUSED
+CALL STACK:
+0: [F] handleTimeout2
+ASYNC CALL STACK:
+1: --- setTimeout ---
+2: [F] handleTimeout1
+3: --- setTimeout ---
+4: [F] triggerNestedSetTimeout
+5: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.SetInterval
+PAUSED
+CALL STACK:
+0: [F] handleInterval
+ASYNC CALL STACK:
+1: --- setInterval ---
+2: [F] triggerSetInterval
+3: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.NestedSetInterval
+PAUSED
+CALL STACK:
+0: [F] handleInterval2
+ASYNC CALL STACK:
+1: --- setInterval ---
+2: [F] handleInterval1
+3: --- setInterval ---
+4: [F] triggerNestedSetInterval
+5: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.NestedSetInterval
+PAUSED
+CALL STACK:
+0: [F] handleInterval2
+ASYNC CALL STACK:
+1: --- setInterval ---
+2: [F] handleInterval1
+3: --- setInterval ---
+4: [F] triggerNestedSetInterval
+5: [P] Global Code
+
+-- Running test case: AsyncStackTrace.Basic.PostMessage
+PAUSED
+CALL STACK:
+0: [F] handleMessage
+ASYNC CALL STACK:
+1: --- postMessage ---
+2: [P] Global Code
+

Added: trunk/LayoutTests/inspector/debugger/async-stack-trace-basic.html (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-basic.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-basic.html	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,115 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function triggerRequestAnimationFrame() {
+    requestAnimationFrame(function handleAnimationFrame() {
+        debugger;
+    });
+}
+
+function triggerNestedRequestAnimationFrame() {
+    requestAnimationFrame(function handleAnimationFrame1() {
+        requestAnimationFrame(function handleAnimationFrame2() {
+            debugger;
+        });
+    });
+}
+
+function triggerSetTimeout() {
+    setTimeout(function handleTimeout() {
+        debugger;
+    });
+}
+
+function triggerNestedSetTimeout() {
+    setTimeout(function handleTimeout1() {
+        setTimeout(function handleTimeout2() {
+            debugger;
+        });
+    });
+}
+
+function triggerSetInterval() {
+    let timer = setInterval(function handleInterval() {
+        clearInterval(timer);
+        debugger;
+    });
+}
+
+function triggerNestedSetInterval() {
+    let outerTimer = setInterval(function handleInterval1() {
+        clearInterval(outerTimer);
+        let innerTimer = setInterval(function handleInterval2() {
+            clearInterval(innerTimer);
+            debugger;
+        });
+    });
+}
+
+function triggerPostMessage() {
+    let frame = document.createElement("iframe");
+    frame.srcdoc = `<script>window.parent.postMessage(42, "*");<\/script>`;
+    document.body.appendChild(frame);
+
+    window.addEventListener("message", function handleMessage() {
+        window.removeEventListener("message", handleMessage);
+        debugger;
+    });
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("AsyncStackTrace.Basic");
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.RequestAnimationFrame",
+        _expression_: "triggerRequestAnimationFrame()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.NestedRequestAnimationFrame",
+        _expression_: "triggerNestedRequestAnimationFrame()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.SetTimeout",
+        _expression_: "triggerSetTimeout()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.NestedSetTimeout",
+        _expression_: "triggerNestedSetTimeout()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.SetInterval",
+        _expression_: "triggerSetInterval()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.NestedSetInterval",
+        _expression_: "triggerNestedSetInterval()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.NestedSetInterval",
+        _expression_: "triggerNestedSetInterval()",
+    });
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.Basic.PostMessage",
+        _expression_: "triggerPostMessage()",
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for checking that async stack traces exist when pausing in asynchronous callbacks: requestAnimationFrame, setTimeout, setInterval, and postMessage.</p>
+</body>
+</html>

Added: trunk/LayoutTests/inspector/debugger/async-stack-trace-event-listener-expected.txt (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-event-listener-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-event-listener-expected.txt	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,33 @@
+Tests for event listener async stack traces.
+
+
+== Running test suite: AsyncStackTrace.EventListener
+-- Running test case: AsyncStackTrace.EventListener.AddEventListener
+PAUSED
+CALL STACK:
+0: [F] handleClick
+1: [F] triggerEventListener
+2: [P] Global Code
+ASYNC CALL STACK:
+3: --- addEventListener ---
+4: [F] triggerEventListener
+5: [P] Global Code
+
+-- Running test case: AsyncStackTrace.EventListener.AddAttributeEventListener
+PAUSED
+CALL STACK:
+0: [F] handleClick
+1: [F] triggerAttributeEventListener
+2: [P] Global Code
+3: [F] triggerAttributeEventListener
+4: [P] Global Code
+
+-- Running test case: AsyncStackTrace.EventListener.ReplaceAttributeEventListener
+PAUSED
+CALL STACK:
+0: [F] handleClick2
+1: [F] replaceAttributeEventListener
+2: [P] Global Code
+3: [F] replaceAttributeEventListener
+4: [P] Global Code
+

Added: trunk/LayoutTests/inspector/debugger/async-stack-trace-event-listener.html (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-event-listener.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-event-listener.html	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,76 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function triggerEventListener() {
+    document.body.addEventListener("click", function handleClick() {
+        document.body.removeEventListener("click", handleClick);
+        debugger;
+    });
+
+    document.body.click();
+}
+
+function triggerAttributeEventListener() {
+    let previousListener = document.body.onclick;
+
+    function handleClick() {
+        document.body._onclick_ = previousListener;
+        debugger;
+    }
+
+    document.body._onclick_ = handleClick;
+    document.body.click();
+}
+
+function replaceAttributeEventListener() {
+    let previousListener = document.body.onclick;
+
+    function handleClick1() {}
+
+    function handleClick2() {
+        document.body._onclick_ = previousListener;
+        debugger;
+    }
+
+    document.body._onclick_ = handleClick1;
+    document.body.addEventListener("click", handleClick1, {once: true});
+    document.body._onclick_ = handleClick2;
+    document.body.click();
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("AsyncStackTrace.EventListener");
+
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.EventListener.AddEventListener",
+        description: "Pause in an event listener handler.",
+        _expression_: "triggerEventListener()"
+    });
+
+    // FIXME: <https://webkit.org/b/183236> Web Inspector: Async stack trace for an on-event handler doesn't include a boundary frame.
+    // Update test results once this has been addressed.
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.EventListener.AddAttributeEventListener",
+        description: "Pause in an attribute event listener handler.",
+        _expression_: "triggerAttributeEventListener()"
+    });
+
+    // Test for <https://webkit.org/b/181580> Web Inspector: ASSERT_NOT_REACHED in PageDebuggerAgent::didAddEventListener when page adds attribute event listener.
+    addAsyncStackTraceTestCase(suite, {
+        name: "AsyncStackTrace.EventListener.ReplaceAttributeEventListener",
+        description: "Replace an attribute event listener after calling addEventListener on the same target.",
+        _expression_: "replaceAttributeEventListener()"
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for event listener async stack traces.</p>
+</body>
+</html>

Deleted: trunk/LayoutTests/inspector/debugger/async-stack-trace-expected.txt (234634 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-expected.txt	2018-08-06 23:49:09 UTC (rev 234634)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-expected.txt	2018-08-06 23:53:33 UTC (rev 234635)
@@ -1,167 +0,0 @@
-CONSOLE MESSAGE: line 83: Unable to post message to http://example.com. Recipient has origin .
-
-Tests for async stack traces.
-
-
-
-== Running test suite: AsyncStackTrace
--- Running test case: CheckAsyncStackTrace.RequestAnimationFrame
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-ASYNC CALL STACK:
-1: --- requestAnimationFrame ---
-2: [F] testRequestAnimationFrame
-3: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.SetTimeout
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-ASYNC CALL STACK:
-1: --- setTimeout ---
-2: [F] testSetTimeout
-3: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.SetInterval
-PAUSE #1
-CALL STACK:
-0: [F] intervalFired
-ASYNC CALL STACK:
-1: --- setInterval ---
-2: [F] testSetInterval
-3: [P] Global Code
-PAUSE #2
-CALL STACK:
-0: [F] intervalFired
-ASYNC CALL STACK:
-1: --- setInterval ---
-2: [F] testSetInterval
-3: [P] Global Code
-PAUSE #3
-CALL STACK:
-0: [F] intervalFired
-ASYNC CALL STACK:
-1: --- setInterval ---
-2: [F] testSetInterval
-3: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.ChainedRequestAnimationFrame
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-ASYNC CALL STACK:
-1: --- requestAnimationFrame ---
-2: [F] testRequestAnimationFrame
-3: --- requestAnimationFrame ---
-4: [F] testChainedRequestAnimationFrame
-5: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.ReferenceCounting
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-ASYNC CALL STACK:
-1: --- setTimeout ---
-2: [F] intervalFired
-3: --- setInterval ---
-4: [F] testReferenceCounting
-5: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.AddEventListener
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-1: [F] clickFired
-2: [F] testAddEventListener
-3: [P] Global Code
-ASYNC CALL STACK:
-4: --- addEventListener ---
-5: [F] testAddEventListener
-6: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.AddAttributeEventListener
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-1: [F] handleClick
-2: [F] testAttributeEventListener
-3: [P] Global Code
-4: [F] testAttributeEventListener
-5: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.ReplaceAttributeEventListener
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-1: [F] handleClick2
-2: [F] testReplaceAttributeEventListener
-3: [P] Global Code
-4: [F] testReplaceAttributeEventListener
-5: [P] Global Code
-
--- Running test case: CheckAsyncStackTrace.PostMessage
-PAUSE #1
-CALL STACK:
-0: [F] pauseThenFinishTest
-1: [F] postMessageFired
-ASYNC CALL STACK:
-2: --- postMessage ---
-3: [F] messageReceived
-4: --- postMessage ---
-5: [F] testPostMessage
-6: [P] Global Code
-
--- Running test case: ShouldNotPauseForFailedPostMessage
-PASS: Should not pause for failed post message.
--- Running test setup.
-Save DebuggerManager.asyncStackTraceDepth
-
--- Running test case: AsyncStackTrace.DisableStackTrace
-PASS: Async stack trace should be null.
--- Running test teardown.
-Restore DebuggerManager.asyncStackTraceDepth
--- Running test setup.
-Save DebuggerManager.asyncStackTraceDepth
-
--- Running test case: AsyncStackTrace.ForceTruncationOnCallStackBoundary
-Set Debugger.asyncStackTraceDepth equal to 4
-PASS: Non-root StackTrace should not be truncated.
-PASS: Non-root StackTrace should not be truncated.
-PASS: StackTrace root should be truncated.
-PASS: StackTrace should be truncated to the nearest call stack.
-CALL STACK:
-0: [F] pauseThenFinishTest
-1: [F] repeat
-ASYNC CALL STACK:
-2: --- requestAnimationFrame ---
-3: [F] repeat
-4: --- requestAnimationFrame ---
-5: [F] repeat
-(remaining call frames truncated)
--- Running test teardown.
-Restore DebuggerManager.asyncStackTraceDepth
--- Running test setup.
-Save DebuggerManager.asyncStackTraceDepth
-
--- Running test case: AsyncStackTrace.ForceTruncationWithinCallStack
-Set Debugger.asyncStackTraceDepth equal to 5
-PASS: Non-root StackTrace should not be truncated.
-PASS: Non-root StackTrace should not be truncated.
-PASS: Non-root StackTrace should not be truncated.
-PASS: StackTrace root should be truncated.
-PASS: StackTrace should be truncated to the nearest call stack.
-CALL STACK:
-0: [F] pauseThenFinishTest
-1: [F] repeat
-ASYNC CALL STACK:
-2: --- requestAnimationFrame ---
-3: [F] repeat
-4: --- requestAnimationFrame ---
-5: [F] repeat
-6: --- requestAnimationFrame ---
-7: [F] repeat
-(remaining call frames truncated)
--- Running test teardown.
-Restore DebuggerManager.asyncStackTraceDepth
-

Added: trunk/LayoutTests/inspector/debugger/async-stack-trace-truncate-expected.txt (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-truncate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-truncate-expected.txt	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,47 @@
+Tests for truncating async stack traces that exceed the maximum async stack trace depth.
+
+
+== Running test suite: AsyncStackTrace.Truncate
+-- Running test setup.
+Set maximum stack trace depth = 0.
+-- Running test case: AsyncStackTrace.DisableAsyncStackTrace
+PAUSED
+CALL STACK:
+0: [F] handleAnimationFrame
+PASS: Async stack trace should be null.
+-- Running test teardown.
+-- Running test setup.
+Set maximum stack trace depth = 10.
+
+-- Running test case: AsyncStackTrace.CheckTruncated
+PAUSED
+CALL STACK:
+0: [F] handleAnimationFrame
+ASYNC CALL STACK:
+1: --- requestAnimationFrame ---
+2: [F] handleAnimationFrame
+3: --- requestAnimationFrame ---
+4: [F] handleAnimationFrame
+5: --- requestAnimationFrame ---
+6: [F] handleAnimationFrame
+7: --- requestAnimationFrame ---
+8: [F] handleAnimationFrame
+9: --- requestAnimationFrame ---
+10: [F] handleAnimationFrame
+(remaining call frames truncated)
+PASS: Async stack trace should be truncated.
+-- Running test teardown.
+-- Running test setup.
+Set maximum stack trace depth = 10.
+
+-- Running test case: AsyncStackTrace.CheckNotTruncated
+PAUSED
+CALL STACK:
+0: [F] handleAnimationFrame
+ASYNC CALL STACK:
+1: --- requestAnimationFrame ---
+2: [F] triggerChainedRequestAnimationFrame
+3: [P] Global Code
+PASS: Async stack trace should not be truncated.
+-- Running test teardown.
+

Added: trunk/LayoutTests/inspector/debugger/async-stack-trace-truncate.html (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace-truncate.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace-truncate.html	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,87 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function triggerChainedRequestAnimationFrame(count) {
+    if (count <= 0)
+        return;
+
+    function handleAnimationFrame() {
+        if (!--count) {
+            debugger;
+            return;
+        }
+        requestAnimationFrame(handleAnimationFrame);
+    }
+
+    requestAnimationFrame(handleAnimationFrame);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("AsyncStackTrace.Truncate");
+
+    function addTruncateTestCase(suite, args) {
+        function setup(resolve) {
+            this.savedStackTraceDepth = WI.debuggerManager.asyncStackTraceDepth;
+            InspectorTest.log(`Set maximum stack trace depth = ${args.maximumStackTraceSize}.`);
+            WI.debuggerManager.asyncStackTraceDepth = args.maximumStackTraceSize;
+            resolve();
+        }
+        function teardown(resolve) {
+            WI.debuggerManager.asyncStackTraceDepth = this.savedStackTraceDepth;
+            resolve();
+        }
+        addAsyncStackTraceTestCase(suite, {...args, setup, teardown});
+    }
+
+    function isTruncated(stackTrace) {
+        while (stackTrace) {
+            if (stackTrace.truncated)
+                return true;
+            stackTrace = stackTrace.parentStackTrace;
+        }
+        return false;
+    }
+
+    addTruncateTestCase(suite, {
+        name: "AsyncStackTrace.DisableAsyncStackTrace",
+        description: "Check that no async stack trace is present when the maximum depth is set to zero.",
+        _expression_: "triggerChainedRequestAnimationFrame(1)",
+        maximumStackTraceSize: 0,
+        pausedHandler(stackTrace) {
+            InspectorTest.expectNull(stackTrace.parentStackTrace, "Async stack trace should be null.");
+        }
+    });
+
+    addTruncateTestCase(suite, {
+        name: "AsyncStackTrace.CheckTruncated",
+        description: "Check that an async stack trace that exceeds the maximum depth is truncated.",
+        _expression_: "triggerChainedRequestAnimationFrame(20)",
+        maximumStackTraceSize: 10,
+        pausedHandler(stackTrace) {
+            InspectorTest.expectThat(isTruncated(stackTrace), "Async stack trace should be truncated.");
+        }
+    });
+
+    addTruncateTestCase(suite, {
+        name: "AsyncStackTrace.CheckNotTruncated",
+        description: "Check that an async stack trace is not truncated when below the maximum depth.",
+        _expression_: "triggerChainedRequestAnimationFrame(1)",
+        maximumStackTraceSize: 10,
+        pausedHandler(stackTrace) {
+            InspectorTest.expectFalse(isTruncated(stackTrace), "Async stack trace should not be truncated.");
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for truncating async stack traces that exceed the maximum async stack trace depth.</p>
+</body>
+</html>

Deleted: trunk/LayoutTests/inspector/debugger/async-stack-trace.html (234634 => 234635)


--- trunk/LayoutTests/inspector/debugger/async-stack-trace.html	2018-08-06 23:49:09 UTC (rev 234634)
+++ trunk/LayoutTests/inspector/debugger/async-stack-trace.html	2018-08-06 23:53:33 UTC (rev 234635)
@@ -1,269 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<script src=""
-<script src=""
-<script>
-const timerDelay = 20;
-
-function pauseThenFinishTest() {
-    debugger;
-    TestPage.dispatchEventToFrontend("AfterTestFunction");
-}
-
-function testRequestAnimationFrame() {
-    requestAnimationFrame(pauseThenFinishTest);
-}
-
-function testSetTimeout() {
-    setTimeout(pauseThenFinishTest, timerDelay);
-}
-
-function testChainedRequestAnimationFrame() {
-    requestAnimationFrame(testRequestAnimationFrame);
-}
-
-function testSetInterval(repeatCount) {
-    let pauses = 0;
-    let timerIdentifier = setInterval(function intervalFired() {
-        debugger;
-        if (++pauses === repeatCount) {
-            clearInterval(timerIdentifier);
-            TestPage.dispatchEventToFrontend("AfterTestFunction");
-        }
-    }, timerDelay);
-}
-
-function testReferenceCounting() {
-    let interval = setInterval(function intervalFired() {
-        clearInterval(interval);
-        setTimeout(pauseThenFinishTest, timerDelay * 2);
-    }, timerDelay);
-}
-
-function testAddEventListener() {
-    document.body.addEventListener("click", function clickFired() {
-        document.body.removeEventListener("click", clickFired);
-        pauseThenFinishTest();
-    });
-
-    document.body.click();
-}
-
-function testAttributeEventListener() {
-    let previousListener = document.body.onclick;
-
-    function handleClick() {
-        document.body._onclick_ = previousListener;
-        pauseThenFinishTest();
-    }
-
-    document.body._onclick_ = handleClick;
-    document.body.click();
-}
-
-function testReplaceAttributeEventListener() {
-    let previousListener = document.body.onclick;
-
-    function handleClick1() {}
-
-    function handleClick2() {
-        document.body._onclick_ = previousListener;
-        pauseThenFinishTest();
-    }
-
-    document.body._onclick_ = handleClick1;
-    document.body.addEventListener("click", handleClick1, {once: true});
-    document.body._onclick_ = handleClick2;
-    document.body.click();
-}
-
-function testPostMessage(targetOrigin = "*") {
-    let childFrame = document.getElementById("postMessageTestFrame");
-    childFrame.contentWindow.postMessage("<message>", targetOrigin);
-
-    window.addEventListener("message", function postMessageFired() {
-        window.removeEventListener("message", postMessageFired);
-        pauseThenFinishTest();
-    });
-}
-
-function testFailPostMessage() {
-    testPostMessage("http://example.com");
-    setTimeout(() => {
-        TestPage.dispatchEventToFrontend("AfterTestFunction");
-    }, 0);
-}
-
-function recursiveCallThenTest(testFunction, depth) {
-    if (depth) {
-        recursiveCallThenTest(testFunction, depth - 1);
-        return;
-    }
-    testFunction();
-}
-
-function repeatingRequestAnimationFrame(repeatCount) {
-    let count = 0;
-    function repeat() {
-        if (count++ === repeatCount) {
-            pauseThenFinishTest();
-            return;
-        }
-        requestAnimationFrame(repeat);
-    }
-    requestAnimationFrame(repeat);
-}
-
-function test()
-{
-    let suite = InspectorTest.createAsyncSuite("AsyncStackTrace");
-
-    function addSimpleTestCase(name, _expression_) {
-        suite.addTestCase({
-            name: `CheckAsyncStackTrace.${name}`,
-            test(resolve, reject) {
-                let pauseCount = 0;
-                function debuggerPaused() {
-                    InspectorTest.log(`PAUSE #${++pauseCount}`);
-                    logActiveStackTrace();
-                    WI.debuggerManager.resume();
-                }
-
-                WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, debuggerPaused);
-
-                InspectorTest.awaitEvent("AfterTestFunction")
-                .then(() => {
-                    WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, debuggerPaused);
-                    resolve();
-                });
-
-                InspectorTest.evaluateInPage(_expression_);
-            }
-        });
-    }
-
-    addSimpleTestCase("RequestAnimationFrame", "testRequestAnimationFrame()");
-    addSimpleTestCase("SetTimeout", "testSetTimeout()");
-    addSimpleTestCase("SetInterval", "testSetInterval(3)");
-    addSimpleTestCase("ChainedRequestAnimationFrame", "testChainedRequestAnimationFrame()");
-    addSimpleTestCase("ReferenceCounting", "testReferenceCounting()");
-    addSimpleTestCase("AddEventListener", "testAddEventListener()");
-    // FIXME: <https://webkit.org/b/183236> Web Inspector: Async stack trace for an on-event handler doesn't include a boundary frame.
-    // Update test results once this has been addressed.
-    addSimpleTestCase("AddAttributeEventListener", "testAttributeEventListener()");
-    // Test for <https://webkit.org/b/181580> Web Inspector: ASSERT_NOT_REACHED in PageDebuggerAgent::didAddEventListener when page adds attribute event listener.
-    addSimpleTestCase("ReplaceAttributeEventListener", "testReplaceAttributeEventListener()");
-    addSimpleTestCase("PostMessage", "testPostMessage()");
-
-    suite.addTestCase({
-        name: "ShouldNotPauseForFailedPostMessage",
-        test(resolve, reject) {
-            function debuggerPaused() {
-                WI.debuggerManager.resume();
-                InspectorTest.fail("Should not pause.");
-                reject();
-            }
-
-            WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, debuggerPaused);
-
-            InspectorTest.awaitEvent("AfterTestFunction")
-            .then(() => {
-                WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, debuggerPaused);
-                InspectorTest.pass("Should not pause for failed post message.");
-                resolve();
-            });
-
-            InspectorTest.evaluateInPage("testFailPostMessage()");
-        }
-    });
-
-    function setup(resolve) {
-        InspectorTest.log("Save DebuggerManager.asyncStackTraceDepth");
-        this.savedCallStackDepth = WI.debuggerManager.asyncStackTraceDepth;
-        resolve();
-    }
-
-    function teardown(resolve) {
-        InspectorTest.log("Restore DebuggerManager.asyncStackTraceDepth");
-        WI.debuggerManager.asyncStackTraceDepth = this.savedCallStackDepth;
-        resolve();
-    }
-
-    suite.addTestCase({
-        name: "AsyncStackTrace.DisableStackTrace",
-        setup,
-        teardown,
-        test(resolve, reject) {
-            WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused)
-            .then((event) => {
-                let stackTrace = getActiveStackTrace();
-                let asyncStackTrace = stackTrace.parentStackTrace;
-                InspectorTest.expectNull(asyncStackTrace, "Async stack trace should be null.");
-                WI.debuggerManager.resume().then(resolve, reject);
-            });
-
-            WI.debuggerManager.asyncStackTraceDepth = 0;
-            InspectorTest.evaluateInPage("testRequestAnimationFrame()");
-        }
-    });
-
-    function addTruncateTestCase(name, asyncStackTraceDepth) {
-        suite.addTestCase({
-            name: `AsyncStackTrace.${name}`,
-            setup,
-            teardown,
-            test(resolve, reject) {
-                // When repeatingRequestAnimationFrame calls rAF, the backend will store a call stack with length 2:
-                // one frame for the caller and one for the asynchronous boundary. As a result, the parity of
-                // Debugger.asyncStackTraceDepth determines whether the trace is truncated on a call stack boundary
-                // (even) or call frame boundary (odd). Since truncation doesn't remove individual call frames,
-                // the depth of the resulting stack trace may exceed the depth setting:
-                //     S = { sšŸ¶, sšŸ·, ā€¦, sš‘˜ }
-                //     T = truncate(S)
-                //     depth(T) ā‰¤ d + depth(tš‘˜)
-                const framesPerCallStack = 2;
-                const expectedStackTraceDepth = asyncStackTraceDepth + (asyncStackTraceDepth % framesPerCallStack);
-
-                WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused)
-                .then((event) => {
-                    let stackTrace = getActiveStackTrace();
-                    InspectorTest.assert(stackTrace && stackTrace.callFrames);
-                    if (!stackTrace || !stackTrace.callFrames)
-                        reject();
-
-                    let stackTraceDepth = 0;
-                    while (stackTrace.parentStackTrace) {
-                        InspectorTest.expectFalse(stackTrace.truncated, "Non-root StackTrace should not be truncated.");
-                        stackTrace = stackTrace.parentStackTrace;
-                        stackTraceDepth += stackTrace.callFrames.length;
-                    }
-
-                    InspectorTest.expectThat(stackTrace.truncated, "StackTrace root should be truncated.");
-                    InspectorTest.expectEqual(stackTraceDepth, expectedStackTraceDepth, "StackTrace should be truncated to the nearest call stack.");
-
-                    logActiveStackTrace();
-                    WI.debuggerManager.resume().then(resolve, reject);
-                });
-
-                InspectorTest.log(`Set Debugger.asyncStackTraceDepth equal to ${asyncStackTraceDepth}`);
-                WI.debuggerManager.asyncStackTraceDepth = asyncStackTraceDepth;
-
-                let repeatCount = Math.floor(asyncStackTraceDepth / framesPerCallStack) + 1;
-                InspectorTest.evaluateInPage(`repeatingRequestAnimationFrame(${repeatCount})`);
-            }
-        });
-    }
-
-    addTruncateTestCase("ForceTruncationOnCallStackBoundary", 4);
-    addTruncateTestCase("ForceTruncationWithinCallStack", 5);
-
-    suite.runTestCasesAndFinish();
-}
-</script>
-</head>
-<body _onload_="runTest()">
-<p>Tests for async stack traces.</p>
-<iframe id="postMessageTestFrame" src=""
-</body>
-</html>

Added: trunk/LayoutTests/inspector/debugger/resources/async-stack-trace-test.js (0 => 234635)


--- trunk/LayoutTests/inspector/debugger/resources/async-stack-trace-test.js	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/resources/async-stack-trace-test.js	2018-08-06 23:53:33 UTC (rev 234635)
@@ -0,0 +1,89 @@
+TestPage.registerInitializer(() => {
+    window.getAsyncStackTrace = function() {
+        InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Active call frame should exist.");
+        if (!WI.debuggerManager.activeCallFrame)
+            return null;
+
+        let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
+        InspectorTest.assert(targetData, "Data for active call frame target should exist.");
+        if (!targetData)
+            return null;
+
+        const topCallFrameIsBoundary = false;
+        const truncated = false;
+        return new WI.StackTrace(targetData.callFrames, topCallFrameIsBoundary, truncated, targetData.asyncStackTrace);
+    };
+
+    window.logAsyncStackTrace = function() {
+        let foundAsyncBoundary = false;
+        let callFrameIndex = 0;
+
+        function logCallFrame(callFrame, isAsyncBoundary) {
+            let label = callFrame.functionName;
+            if (isAsyncBoundary)
+                InspectorTest.log(`${callFrameIndex}: --- ${label} ---`);
+            else {
+                let code = callFrame.nativeCode ? "N" : (callFrame.programCode ? "P" : "F");
+                InspectorTest.log(`${callFrameIndex}: [${code}] ${label}`);
+            }
+            callFrameIndex++;
+        }
+
+        InspectorTest.log("CALL STACK:");
+
+        let stackTrace = getAsyncStackTrace();
+        while (stackTrace) {
+            let callFrames = stackTrace.callFrames;
+            let topCallFrameIsBoundary = stackTrace.topCallFrameIsBoundary;
+            let truncated = stackTrace.truncated;
+            stackTrace = stackTrace.parentStackTrace;
+            if (!callFrames || !callFrames.length)
+                continue;
+
+            if (topCallFrameIsBoundary) {
+                if (!foundAsyncBoundary) {
+                    InspectorTest.log("ASYNC CALL STACK:");
+                    foundAsyncBoundary = true;
+                }
+                logCallFrame(callFrames[0], true);
+            }
+
+            for (let i = topCallFrameIsBoundary ? 1 : 0; i < callFrames.length; ++i) {
+                let callFrame = callFrames[i];
+                logCallFrame(callFrame);
+
+                // Skip call frames after the test harness entry point.
+                if (callFrame.programCode)
+                    break;
+            }
+
+            if (truncated)
+                InspectorTest.log("(remaining call frames truncated)");
+        }
+    };
+
+    window.addAsyncStackTraceTestCase = function(suite, {name, description, _expression_, pausedHandler, setup, teardown}) {
+        suite.addTestCase({
+            name,
+            description,
+            setup,
+            teardown,
+            async test(resolve, reject) {
+                let result = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused)
+                .then(() => {
+                    InspectorTest.log("PAUSED");
+                    logAsyncStackTrace();
+
+                    if (pausedHandler)
+                        pausedHandler(getAsyncStackTrace());
+
+                    WI.debuggerManager.resume();
+                })
+                .then(() => WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed));
+
+                InspectorTest.evaluateInPage(_expression_);
+                await result;
+            }
+        });
+    };
+});

Deleted: trunk/LayoutTests/inspector/debugger/resources/postMessage-echo.html (234634 => 234635)


--- trunk/LayoutTests/inspector/debugger/resources/postMessage-echo.html	2018-08-06 23:49:09 UTC (rev 234634)
+++ trunk/LayoutTests/inspector/debugger/resources/postMessage-echo.html	2018-08-06 23:53:33 UTC (rev 234635)
@@ -1,6 +0,0 @@
-<script>
-window.addEventListener("message", function messageReceived(event) {
-    let echo = `iFrame postMessage echo: ${event.data}`;
-    parent.postMessage(echo, "*");
-});
-</script>

Modified: trunk/LayoutTests/platform/mac/TestExpectations (234634 => 234635)


--- trunk/LayoutTests/platform/mac/TestExpectations	2018-08-06 23:49:09 UTC (rev 234634)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2018-08-06 23:53:33 UTC (rev 234635)
@@ -1073,7 +1073,6 @@
 webkit.org/b/148636 inspector/css/pseudo-element-matches-for-pseudo-element-node.html [ Pass Timeout ]
 webkit.org/b/148636 inspector/css/selector-dynamic-specificity.html [ Pass Timeout ]
 webkit.org/b/148636 inspector/css/selector-specificity.html [ Pass Timeout ]
-webkit.org/b/165584 inspector/debugger/async-stack-trace.html [ Pass Timeout ]
 webkit.org/b/158742 [ Debug ] inspector/debugger/break-in-constructor-before-super.html [ Pass Timeout ]
 webkit.org/b/163604 inspector/debugger/breakpoint-action-eval.html [ Pass Timeout ]
 webkit.org/b/168338 [ Sierra ] inspector/debugger/breakpoint-action-detach.html [ Pass Timeout ]
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to