Changeset 202784 in webkit


Ignore:
Timestamp:
Jul 2, 2016 8:33:34 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

inspector/debugger/command-line-api-exception.html flakily times out on mac
https://bugs.webkit.org/show_bug.cgi?id=152029
<rdar://problem/23813812>

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2016-07-02
Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

  • UserInterface/Base/Object.js:

(WebInspector.Object.addEventListener):
Return the listener, this makes it cleaner to write tests.

LayoutTests:

  • inspector/debugger/command-line-api-exception-expected.txt:
  • inspector/debugger/command-line-api-exception-nested-catch-expected.txt:
  • inspector/debugger/command-line-api-exception-nested-catch.html:
  • inspector/debugger/command-line-api-exception.html:
  • platform/mac/TestExpectations:

Rewrite these tests to use the new test harness.
This also is more careful about Pause/Resume timing differences
between Release and Debug builds.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202783 r202784  
     12016-07-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        inspector/debugger/command-line-api-exception.html flakily times out on mac
     4        https://bugs.webkit.org/show_bug.cgi?id=152029
     5        <rdar://problem/23813812>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/debugger/command-line-api-exception-expected.txt:
     10        * inspector/debugger/command-line-api-exception-nested-catch-expected.txt:
     11        * inspector/debugger/command-line-api-exception-nested-catch.html:
     12        * inspector/debugger/command-line-api-exception.html:
     13        * platform/mac/TestExpectations:
     14        Rewrite these tests to use the new test harness.
     15        This also is more careful about Pause/Resume timing differences
     16        between Release and Debug builds.
     17
    1182016-07-02  Joseph Pecoraro  <pecoraro@apple.com>
    219
  • trunk/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt

    r201083 r202784  
    1313Checks that $exception is available and accurate in evaluations when paused on an exception.
    1414
    15 BEFORE: $exception => undefined
    16 PAUSE #1: $exception => TypeError: undefined is not an object (evaluating '[].x.x')
    17 PAUSE #2: $exception => ReferenceError: Can't find variable: variableThatDoesNotExist
    18 PAUSE #3: $exception => SyntaxError: Unexpected token ')'
    19 PAUSE #4: $exception => Error: IndexSizeError: DOM Exception 1
    20 PAUSE #5: $exception => thrown string
    21 PAUSE #6: $exception => 123.456
    22 PAUSE #7: $exception => null
    23 PAUSE #8: $exception => Object
    24 PAUSE #9: $exception => <body>
    25 PAUSE #10: $exception => TypeError: undefined is not an object (evaluating '[].x.x')
    26 STEPPED OUT TO CATCH BLOCK: $exception === e ? true
    27 PAUSE #11: $exception => thrown string
    28 STEPPED OUT TO CATCH BLOCK: $exception === e ? true
    29 PAUSE #12: $exception => Object
    30 STEPPED OUT TO CATCH BLOCK: $exception === e ? true
    31 AFTER: $exception => undefined
    3215
     16== Running test suite: CommandLineAPI.$exception
     17-- Running test case: BeforeExceptions
     18PASS: $exception should be undefined if there is no exception.
     19
     20-- Running test case: UncaughtTypeException
     21$exception => TypeError: undefined is not an object (evaluating '[].x.x')
     22
     23-- Running test case: UncaughtReferenceException
     24$exception => ReferenceError: Can't find variable: variableThatDoesNotExist
     25
     26-- Running test case: UncaughtSyntaxException
     27$exception => SyntaxError: Unexpected token ')'
     28
     29-- Running test case: UncaughtDOMException
     30$exception => Error: IndexSizeError: DOM Exception 1
     31
     32-- Running test case: UncaughtString
     33$exception => thrown string
     34
     35-- Running test case: UncaughtNumber
     36$exception => 123.456
     37
     38-- Running test case: UncaughtNull
     39$exception => null
     40
     41-- Running test case: UncaughtObject
     42$exception => Object
     43
     44-- Running test case: UncaughtNode
     45$exception => <body>
     46
     47-- Running test case: CatchTypeException
     48PASS: Paused, stepping out to catch block...
     49PASS: `$exception` should be equal to `e`.
     50$exception => TypeError: undefined is not an object (evaluating '[].x.x')
     51
     52-- Running test case: CatchThrownString
     53PASS: Paused, stepping out to catch block...
     54PASS: `$exception` should be equal to `e`.
     55$exception => thrown string
     56
     57-- Running test case: CatchThrownObject
     58PASS: Paused, stepping out to catch block...
     59PASS: `$exception` should be equal to `e`.
     60$exception => Object
     61
     62-- Running test case: AfterExceptions
     63PASS: $exception should be undefined if there is no exception.
     64
  • trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt

    r176357 r202784  
    33Checks that $exception is the value of the current exception, even in nested catch blocks.
    44
    5 BEFORE : $exception => undefined
     5
     6== Running test suite: CommandLineAPI.$exception
     7-- Running test case: EmptyBefore
     8PASS: $exception should be undefined if there is no exception.
     9
     10-- Running test case: CheckExceptionInsideNestedCatchBlocks
    611OUTER 1: $exception => outer exception
    712INNER 1: $exception => inner exception
     
    1015OUTER 2: $exception => outer exception
    1116  CATCH: $exception === e1 ? true
    12 AFTER  : $exception => undefined
    1317
     18-- Running test case: EmptyAfter
     19PASS: $exception should be undefined if there is no exception.
     20
  • trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html

    r201855 r202784  
    1 <!doctype html>
     1<!DOCTYPE html>
    22<html>
    33<head>
    4 <script type="text/javascript" src="../../http/tests/inspector/resources/inspector-test.js"></script>
    5 <script type="text/javascript" src="./resources/exceptions.js"></script>
     4<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="resources/exceptions.js"></script>
    66<script>
    7 function triggerException()
    8 {
    9     // We expect uncaught exceptions, so avoid logs for them.
    10     window.onerror = function(){};
    11     setTimeout(nestedCatchBlocks, 0);
    12 }
     7window.onerror = function(){};
    138
    149function test()
     
    2823    }
    2924
    30     var done = false;
    31     var phase = 0;
    3225
    33     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, function(event) {
    34         if (done)
    35             return;
     26    let suite = InspectorTest.createAsyncSuite("CommandLineAPI.$exception");
    3627
    37         phase++;
    38 
    39         // Skip past the first pause to the second pause.
    40         if (phase === 1) {
    41             dumpCommandLineAPIValue("OUTER 1");
    42             WebInspector.debuggerManager.resume();
    43             return;
    44         }
    45 
    46         // Paused on the exception in the inner try, step over to get into the inner catch.
    47         if (phase === 2) {
    48             dumpCommandLineAPIValue("INNER 1");
    49             WebInspector.debuggerManager.stepOver();
    50             return;
    51         }
    52 
    53         // Paused in the inner catch, verify $exception is "inner exception".
    54         if (phase === 3) {
    55             dumpCommandLineAPIValue("INNER 2");
    56             checkIfExceptionValueMatchesVariable("e2");
    57             WebInspector.debuggerManager.stepOver();
    58             return;
    59         }
    60        
    61         // Stepped into the outer catch, verify $exception is "outer exception".
    62         if (phase === 4) {
    63             dumpCommandLineAPIValue("OUTER 2");
    64             checkIfExceptionValueMatchesVariable("e1");
    65             WebInspector.debuggerManager.resume();
    66             return;
     28    suite.addTestCase({
     29        name: "EmptyBefore",
     30        description: "Without exceptions, $exception should be undefined",
     31        test: (resolve, reject) => {
     32            WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => {
     33                InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception.");
     34                resolve();
     35            });
    6736        }
    6837    });
    6938
    70     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, function(event) {
    71         done = true;
    72         dumpCommandLineAPIValue("AFTER  ");
    73         InspectorTest.completeTest();
     39    suite.addTestCase({
     40        name: "CheckExceptionInsideNestedCatchBlocks",
     41        description: "Check $exception is always the current exception object when stepping through catch blocks.",
     42        test: (resolve, reject) => {
     43            InspectorTest.evaluateInPage("setTimeout(nestedCatchBlocks, 0)");
     44
     45            let phase = 0;
     46            let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) => {
     47                if (!WebInspector.debuggerManager.activeCallFrame)
     48                    return;
     49
     50                phase++;
     51
     52                // Skip past the first pause to the second pause.
     53                if (phase === 1) {
     54                    dumpCommandLineAPIValue("OUTER 1");
     55                    WebInspector.debuggerManager.resume();
     56                    return;
     57                }
     58
     59                // Paused on the exception in the inner try, step over to get into the inner catch.
     60                if (phase === 2) {
     61                    dumpCommandLineAPIValue("INNER 1");
     62                    WebInspector.debuggerManager.stepOver();
     63                    return;
     64                }
     65
     66                // Paused in the inner catch, verify $exception is "inner exception".
     67                if (phase === 3) {
     68                    dumpCommandLineAPIValue("INNER 2");
     69                    checkIfExceptionValueMatchesVariable("e2");
     70                    WebInspector.debuggerManager.stepOver();
     71                    return;
     72                }
     73       
     74                // Stepped into the outer catch, verify $exception is "outer exception".
     75                if (phase === 4) {
     76                    dumpCommandLineAPIValue("OUTER 2");
     77                    checkIfExceptionValueMatchesVariable("e1");
     78                    WebInspector.debuggerManager.resume().then(() => {
     79                        WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, listener);
     80                        resolve();
     81                    }, reject);
     82                    return;
     83                }
     84            });
     85        }
    7486    });
    7587
    76     dumpCommandLineAPIValue("BEFORE ");
    77     InspectorTest.evaluateInPage("triggerException()");
     88    suite.addTestCase({
     89        name: "EmptyAfter",
     90        description: "Without exceptions, $exception should be undefined",
     91        test: (resolve, reject) => {
     92            WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => {
     93                InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception.");
     94                resolve();
     95            });
     96        }
     97    });
     98
     99    suite.runTestCasesAndFinish();
    78100}
    79101</script>
    80102</head>
    81103<body onload="runTest()">
    82     <p>Checks that <code>$exception</code> is the value of the current exception, even in nested catch blocks.</p>
     104<p>Checks that <code>$exception</code> is the value of the current exception, even in nested catch blocks.</p>
    83105</body>
    84106</html>
  • trunk/LayoutTests/inspector/debugger/command-line-api-exception.html

    r201855 r202784  
    1 <!doctype html>
     1<!DOCTYPE html>
    22<html>
    33<head>
    4 <script type="text/javascript" src="../../http/tests/inspector/resources/inspector-test.js"></script>
    5 <script type="text/javascript" src="./resources/exceptions.js"></script>
     4<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="./resources/exceptions.js"></script>
    66<script>
    7 var exceptionIndex = 0;
    8 var exceptionCausers = [
    9     triggerUncaughtTypeException,
    10     triggerUncaughtReferenceException,
    11     triggerUncaughtSyntaxException,
    12     triggerUncaughtDOMException,
    13     throwString,
    14     throwNumber,
    15     throwNull,
    16     throwObject,
    17     throwNode,
    18     function() { catcher(triggerUncaughtTypeException); },
    19     function() { catcher(throwString); },
    20     function() { catcher(throwObject); },
    21 ];
    22 
    23 
    24 function triggerNextException()
    25 {
    26     // We expect uncaught exceptions, so avoid logs for them.
    27     window.onerror = function(){};
    28 
    29     setTimeout(function() {
    30         exceptionCausers[exceptionIndex++]();
    31     }, 0);
    32 }
     7// We expect uncaught exceptions, so avoid logs for them.
     8window.onerror = function(){};
    339
    3410function test()
     
    3612    WebInspector.debuggerManager.allExceptionsBreakpoint.disabled = false;
    3713
    38     function triggerNextException() {
    39         InspectorTest.evaluateInPage("triggerNextException()");
    40     }
     14    let suite = InspectorTest.createAsyncSuite("CommandLineAPI.$exception");
    4115
    42     function dumpCommandLineAPIValue(prefix) {
    43         WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, function(result, wasThrown) {
    44             InspectorTest.log(prefix + ": $exception => " + result.description);
     16    function addNoExceptionTest(name) {
     17        suite.addTestCase({
     18            name, description: "Without exceptions, $exception should be undefined",
     19            test: (resolve, reject) => {
     20                WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => {
     21                    InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception.");
     22                    resolve();
     23                });
     24            }
    4525        });
    4626    }
    4727
    48     function checkIfExceptionValueMatchesCatchVariable() {
    49         WebInspector.runtimeManager.evaluateInInspectedWindow("$exception === e", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, function(result, wasThrown) {
    50             InspectorTest.log("STEPPED OUT TO CATCH BLOCK: $exception === e ? " + result.description);
     28    function addUncaughtExceptionTest(name, testFunction) {
     29        suite.addTestCase({
     30            name, description: "Trigger an uncaught exception and check $exception.",
     31            test: (resolve, reject) => {
     32                InspectorTest.evaluateInPage(`setTimeout(${testFunction})`);
     33                WebInspector.debuggerManager.singleFireEventListener(WebInspector.DebuggerManager.Event.Paused, (event) => {
     34                    WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => {
     35                        InspectorTest.log("$exception => " + result.description);
     36                        WebInspector.debuggerManager.resume().then(resolve, reject);
     37                    });
     38                });
     39            }
    5140        });
    5241    }
    5342
    54     var pauses = 0;
    55     var stepping = false;
    56     var done = false;
    57     const pointWhereExpectionsAreBeingCaught = 9;
    58     const expectedPauses = 12;
     43    function addCaughtExceptionTest(name, expression) {
     44        suite.addTestCase({
     45            name, description: "Trigger a caught exception and check $exception.",
     46            test: (resolve, reject) => {
     47                InspectorTest.evaluateInPage(expression);
    5948
    60     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, function(event) {
    61         if (done)
    62             return;
     49                let didStep = false;
     50                let didEvaluate = false;
    6351
    64         if (!stepping) {
    65             dumpCommandLineAPIValue("PAUSE #" + (++pauses));
    66             if (pauses > pointWhereExpectionsAreBeingCaught) {
    67                 WebInspector.debuggerManager.stepOut();
    68                 stepping = true;
    69                 return;
     52                let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, (event) => {
     53                    if (!WebInspector.debuggerManager.activeCallFrame)
     54                        return;
     55
     56                    if (!didStep) {
     57                        didStep = true;
     58                        InspectorTest.pass("Paused, stepping out to catch block...");
     59                        WebInspector.debuggerManager.stepOut();
     60                        return;
     61                    }
     62
     63                    if (!didEvaluate) {
     64                        didEvaluate = true;
     65                        WebInspector.runtimeManager.evaluateInInspectedWindow("$exception === e", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => {
     66                            InspectorTest.expectThat(result.description === "true", "`$exception` should be equal to `e`.");
     67                        });
     68                        WebInspector.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => {
     69                            InspectorTest.log("$exception => " + result.description);
     70                            WebInspector.debuggerManager.resume().then(() => {
     71                                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.CallFramesDidChange, listener);
     72                                resolve();
     73                            }, reject);
     74                        });
     75                        return;
     76                    }
     77                });
    7078            }
    71         } else {
    72             checkIfExceptionValueMatchesCatchVariable();
    73             stepping = false;
    74         }
     79        });
     80    }
    7581
    76         WebInspector.debuggerManager.resume();
     82    addNoExceptionTest("BeforeExceptions");
    7783
    78         if (pauses !== expectedPauses) {
    79             triggerNextException();
    80             return;
    81         }
    82     });
     84    addUncaughtExceptionTest("UncaughtTypeException", "triggerUncaughtTypeException");
     85    addUncaughtExceptionTest("UncaughtReferenceException", "triggerUncaughtReferenceException");
     86    addUncaughtExceptionTest("UncaughtSyntaxException", "triggerUncaughtSyntaxException");
     87    addUncaughtExceptionTest("UncaughtDOMException", "triggerUncaughtDOMException");
     88    addUncaughtExceptionTest("UncaughtString", "throwString");
     89    addUncaughtExceptionTest("UncaughtNumber", "throwNumber");
     90    addUncaughtExceptionTest("UncaughtNull", "throwNull");
     91    addUncaughtExceptionTest("UncaughtObject", "throwObject");
     92    addUncaughtExceptionTest("UncaughtNode", "throwNode");
    8393
    84     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, function(event) {
    85         done = true;
    86         dumpCommandLineAPIValue("AFTER");
    87         InspectorTest.completeTest();
    88     });
     94    addCaughtExceptionTest("CatchTypeException", "setTimeout(function() { catcher(triggerUncaughtTypeException); })");
     95    addCaughtExceptionTest("CatchThrownString", "setTimeout(function() { catcher(throwString); })");
     96    addCaughtExceptionTest("CatchThrownObject", "setTimeout(function() { catcher(throwObject); })");
    8997
    90     dumpCommandLineAPIValue("BEFORE");
    91     triggerNextException();
     98    addNoExceptionTest("AfterExceptions");
     99
     100    suite.runTestCasesAndFinish();
    92101}
    93102</script>
    94103</head>
    95104<body onload="runTest()">
    96     <p>Checks that <code>$exception</code> is available and accurate in evaluations when paused on an exception.</p>
     105<p>Checks that <code>$exception</code> is available and accurate in evaluations when paused on an exception.</p>
    97106</body>
    98107</html>
  • trunk/LayoutTests/platform/mac/TestExpectations

    r202783 r202784  
    12111211webkit.org/b/153460 [ Debug ] inspector/codemirror/prettyprinting-css-rules.html [ Pass Timeout ]
    12121212webkit.org/b/158742 [ Debug ] inspector/debugger/break-in-constructor-before-super.html [ Pass Timeout ]
    1213 webkit.org/b/152029 inspector/debugger/command-line-api-exception.html [ Pass Timeout ]
    1214 webkit.org/b/152487 inspector/debugger/command-line-api-exception-nested-catch.html [ Pass Timeout ]
    12151213webkit.org/b/148636 inspector/dom/content-flow-content-nodes.html [ Pass Timeout ]
    12161214webkit.org/b/148636 inspector/dom/content-flow-content-removal.html [ Pass Timeout ]
  • trunk/Source/WebInspectorUI/ChangeLog

    r202742 r202784  
     12016-07-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        inspector/debugger/command-line-api-exception.html flakily times out on mac
     4        https://bugs.webkit.org/show_bug.cgi?id=152029
     5        <rdar://problem/23813812>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * UserInterface/Base/Object.js:
     10        (WebInspector.Object.addEventListener):
     11        Return the listener, this makes it cleaner to write tests.
     12
    1132016-07-01  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Base/Object.js

    r201171 r202784  
    5555
    5656        listenersTable.add(thisObject, listener);
     57        return listener;
    5758    }
    5859
Note: See TracChangeset for help on using the changeset viewer.