| Index: third_party/WebKit/LayoutTests/imported/wpt/html/dom/original-harness.js
|
| diff --git a/third_party/WebKit/LayoutTests/imported/wpt/html/dom/original-harness.js b/third_party/WebKit/LayoutTests/imported/wpt/html/dom/original-harness.js
|
| index 113da5f9b287f9d87df95a369cb0812183970a2f..3cfa05bcb8d7d3c46062ebe552f1e6d80f27487c 100644
|
| --- a/third_party/WebKit/LayoutTests/imported/wpt/html/dom/original-harness.js
|
| +++ b/third_party/WebKit/LayoutTests/imported/wpt/html/dom/original-harness.js
|
| @@ -5,10 +5,13 @@
|
| ReflectionHarness.failed = document.getElementById("failed");
|
|
|
| /**
|
| - * In conformance testing mode, all tests will be run. Otherwise, we'll skip
|
| - * tests for attributes that have an entirely incorrect type.
|
| - */
|
| -ReflectionHarness.conformanceTesting = false;
|
| + * Should we report a failure for unexpected exceptions, or just rethrow them?
|
| + * The original test framework reports an exception, but testharness.js doesn't
|
| + * want that.
|
| + *
|
| + * @public
|
| + */
|
| +ReflectionHarness.catchUnexpectedExceptions = true;
|
|
|
| /**
|
| * Returns a string representing val. Basically just adds quotes for strings,
|
| @@ -83,28 +86,12 @@
|
| ReflectionHarness.currentTestInfo = {};
|
|
|
| /**
|
| - * .test() sets this, and it's used by .assertEquals()/.assertThrows().
|
| - * Calling .test() recursively is an error.
|
| - */
|
| -ReflectionHarness.currentTestDescription = null;
|
| -
|
| -/**
|
| - * Run a group of one or more assertions. If any exceptions are thrown, catch
|
| - * them and report a failure.
|
| - */
|
| -ReflectionHarness.test = function(fn, description) {
|
| - if (this.currentTestDescription) {
|
| - throw "TEST BUG: test() may not be called recursively!";
|
| - }
|
| - this.currentTestDescription = description;
|
| - try {
|
| - fn();
|
| - // Not throwing is a success
|
| - this.success();
|
| - } catch(err) {
|
| - this.failure("Exception thrown during tests with " + description);
|
| - }
|
| - this.currentTestDescription = null;
|
| + * This is called when we want to test a single element/attribute combination.
|
| + * For the original harness, it does nothing special (just calls the function),
|
| + * but for testharness.js, it can wrap everything in a test() call.
|
| + */
|
| +ReflectionHarness.testWrapper = function(fn) {
|
| + fn();
|
| }
|
|
|
| /**
|
| @@ -115,29 +102,37 @@
|
| *
|
| * @public
|
| */
|
| -ReflectionHarness.assertEquals = function(expected, actual, description) {
|
| +ReflectionHarness.test = function(expected, actual, description) {
|
| // Special-case -0 yay!
|
| if (expected === 0 && actual === 0 && 1/expected === 1/actual) {
|
| this.increment(this.passed);
|
| + return true;
|
| } else if (expected === actual) {
|
| this.increment(this.passed);
|
| + return true;
|
| } else {
|
| this.increment(this.failed);
|
| - this.reportFailure(this.currentTestDescription +
|
| - (description ? " followed by " + description : "") +
|
| - ' (expected ' + this.stringRep(actual) + ', got ' +
|
| - this.stringRep(expected) + ')');
|
| + this.reportFailure(description + ' (expected ' + this.stringRep(actual) + ', got ' + this.stringRep(expected) + ')');
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +ReflectionHarness.run = function(fun, description) {
|
| + try {
|
| + fun();
|
| + } catch (err) {
|
| + ReflectionHarness.failure(description);
|
| }
|
| }
|
|
|
| /**
|
| * If calling fn causes a DOMException of the type given by the string
|
| - * exceptionName (e.g., "IndexSizeError"), output a success. Otherwise, report
|
| - * a failure.
|
| - *
|
| - * @public
|
| - */
|
| -ReflectionHarness.assertThrows = function(exceptionName, fn) {
|
| + * exceptionName (e.g., "INDEX_SIZE_ERR"), output a success. Otherwise, report
|
| + * a failure with the given description.
|
| + *
|
| + * @public
|
| + */
|
| +ReflectionHarness.testException = function(exceptionName, fn, description) {
|
| try {
|
| fn();
|
| } catch (e) {
|
| @@ -147,8 +142,7 @@
|
| }
|
| }
|
| this.increment(this.failed);
|
| - this.reportFailure(this.currentTestDescription + " must throw " +
|
| - exceptionName);
|
| + this.reportFailure(description);
|
| return false;
|
| }
|
|
|
| @@ -254,9 +248,9 @@
|
| }
|
|
|
| /**
|
| - * Shorthand function for when we have a failure outside of
|
| - * assertEquals()/assertThrows(). Generally used when the failure is an
|
| - * exception thrown unexpectedly or such, something not equality-based.
|
| + * Shorthand function for when we have a failure outside of test(). Generally
|
| + * used when the failure is an exception thrown unexpectedly or such, something
|
| + * not equality-based.
|
| *
|
| * @public
|
| */
|
| @@ -266,8 +260,8 @@
|
| }
|
|
|
| /**
|
| - * Shorthand function for when we have a success outside of
|
| - * assertEquals()/assertThrows().
|
| + * Shorthand function for when we have a success outside of test(). Only
|
| + * called if catchUnexpectedExceptions is true.
|
| *
|
| * @public
|
| */
|
|
|