Changeset 225814 in webkit


Ignore:
Timestamp:
Dec 12, 2017 3:13:04 PM (6 years ago)
Author:
BJ Burg
Message:

Web Inspector: SyncTestSuite should complain if passed an async setup/test/teardown function
https://bugs.webkit.org/show_bug.cgi?id=180717

Reviewed by Devin Rousso.

Source/WebInspectorUI:

  • UserInterface/Test/TestSuite.js:

(SyncTestSuite.prototype.addTestCase):
Raise an exception if test/setup/teardown is an async function. It won't work.

LayoutTests:

Add new test cases for more strict requirements for test case arguments.

  • inspector/unit-tests/sync-test-suite-expected.txt:
  • inspector/unit-tests/sync-test-suite.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r225812 r225814  
     12017-12-12  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: SyncTestSuite should complain if passed an async setup/test/teardown function
     4        https://bugs.webkit.org/show_bug.cgi?id=180717
     5
     6        Reviewed by Devin Rousso.
     7
     8        Add new test cases for more strict requirements for test case arguments.
     9
     10        * inspector/unit-tests/sync-test-suite-expected.txt:
     11        * inspector/unit-tests/sync-test-suite.html:
     12
    1132017-12-12  Antoine Quint  <graouts@apple.com>
    214
  • trunk/LayoutTests/inspector/unit-tests/sync-test-suite-expected.txt

    r210367 r225814  
    1414PASS: should not be able to specify non-Function `teardown` parameter.
    1515PASS: should not be able to specify non-Function `teardown` parameter.
     16PASS: should not be able to specify async `test` parameter.
     17PASS: should not be able to specify async `setup` parameter.
     18PASS: should not be able to specify async `teardown` parameter.
    1619PASS: should not be able to run empty test suite.
    1720
  • trunk/LayoutTests/inspector/unit-tests/sync-test-suite.html

    r210367 r225814  
    136136        ProtocolTest.log("PASS: should not be able to specify non-Function `teardown` parameter.");
    137137    }
     138    try {
     139        badArgsSuite.addTestCase({
     140            name: "foo",
     141            async test() {},
     142        });
     143        ProtocolTest.log("FAIL: should not be able to specify async `test` parameter.");
     144    } catch (e) {
     145        ProtocolTest.log("PASS: should not be able to specify async `test` parameter.");
     146    }
     147    try {
     148        badArgsSuite.addTestCase({
     149            name: "foo",
     150            async setup() {},
     151            test() {},
     152        });
     153        ProtocolTest.log("FAIL: should not be able to specify async `setup` parameter.");
     154    } catch (e) {
     155        ProtocolTest.log("PASS: should not be able to specify async `setup` parameter.");
     156    }
     157    try {
     158        badArgsSuite.addTestCase({
     159            name: "foo",
     160            test() {},
     161            async teardown() {},
     162        });
     163        ProtocolTest.log("FAIL: should not be able to specify async `teardown` parameter.");
     164    } catch (e) {
     165        ProtocolTest.log("PASS: should not be able to specify async `teardown` parameter.");
     166    }
     167
    138168    let runEmptySuite = ProtocolTest.createSyncSuite("SyncTestSuite.RunEmptySuite");
    139169    try {
  • trunk/Source/WebInspectorUI/ChangeLog

    r225810 r225814  
     12017-12-12  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: SyncTestSuite should complain if passed an async setup/test/teardown function
     4        https://bugs.webkit.org/show_bug.cgi?id=180717
     5
     6        Reviewed by Devin Rousso.
     7
     8        * UserInterface/Test/TestSuite.js:
     9        (SyncTestSuite.prototype.addTestCase):
     10        Raise an exception if test/setup/teardown is an async function. It won't work.
     11
    1122017-12-12  Brian Burg  <bburg@apple.com>
    213
  • trunk/Source/WebInspectorUI/UserInterface/Test/TestSuite.js

    r223809 r225814  
    176176SyncTestSuite = class SyncTestSuite extends TestSuite
    177177{
     178    addTestCase(testcase)
     179    {
     180        if ([testcase.setup, testcase.teardown, testcase.test].some((fn) => fn && fn[Symbol.toStringTag] === "AsyncFunction"))
     181            throw new Error("Tried to pass a test case with an async `setup`, `test`, or `teardown` function, but this is a synchronous test suite.")
     182
     183        super.addTestCase(testcase);
     184    }
     185
    178186    runTestCasesAndFinish()
    179187    {
Note: See TracChangeset for help on using the changeset viewer.