diff options
author | jsbell@chromium.org <jsbell@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2013-11-23 12:50:18 +0000 |
---|---|---|
committer | jsbell@chromium.org <jsbell@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2013-11-23 12:50:18 +0000 |
commit | a63406df5332fee95e2be4da39eb2312699a14f6 (patch) | |
tree | a36cc77ef392d90787ae0df97c9d2bc795548136 | |
parent | 9d3c796f94da2b451b591a38f6eb75d984751206 (diff) | |
download | chromium_src-a63406df5332fee95e2be4da39eb2312699a14f6.zip chromium_src-a63406df5332fee95e2be4da39eb2312699a14f6.tar.gz chromium_src-a63406df5332fee95e2be4da39eb2312699a14f6.tar.bz2 |
js-test.js: Make shouldBeFoo(expr, quiet) actually use quiet flag
A handful of tests pass in a |quiet| flag that's not implemented.
Fix it by actually implementing it and updating tests/results.
Also, make use of _-prefixed arguments and variables consistent
in functions that call eval() (to protect them) and don't prefix
them in functions that do not call eval().
R=ojan@chromium.org
Review URL: https://codereview.chromium.org/84123002
git-svn-id: svn://svn.chromium.org/blink/trunk@162583 bbb929c8-8fbe-4397-9dbb-9b2b20218538
7 files changed, 110 insertions, 142 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/resources/id-fastpath-almost-strict.js b/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/resources/id-fastpath-almost-strict.js index dc97198..a00ee6c 100644 --- a/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/resources/id-fastpath-almost-strict.js +++ b/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/resources/id-fastpath-almost-strict.js @@ -10,10 +10,10 @@ document.body.appendChild(root); shouldBe("document.querySelector('#testId')", "correctNode"); shouldBe("document.querySelector('div#testId')", "correctNode"); -shouldBeNull("document.querySelector('ul#testId')", "correctNode"); -shouldBeNull("document.querySelector('ul #testId')", "correctNode"); -shouldBeNull("document.querySelector('#testId[attr]')", "correctNode"); -shouldBeNull("document.querySelector('#testId:not(div)')", "correctNode"); +shouldBeNull("document.querySelector('ul#testId')"); +shouldBeNull("document.querySelector('ul #testId')"); +shouldBeNull("document.querySelector('#testId[attr]')"); +shouldBeNull("document.querySelector('#testId:not(div)')"); shouldBe("document.querySelectorAll('div#testId').length", "1"); shouldBe("document.querySelectorAll('div#testId').item(0)", "correctNode"); diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/calendar-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/calendar-picker-key-operations.html index 3b7c3cc..cd26451 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/calendar-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/calendar-picker-key-operations.html @@ -20,7 +20,7 @@ openPicker(document.getElementById('date'), test1); function test1() { debug('Check that page popup exists.'); shouldBe('popupWindow.pagePopupController.toString()', '"[object PagePopupController]"'); - + shouldBeFalse('isCalendarTableScrollingWithAnimation()'); shouldBeEqualToString('currentMonth()', '2000-01'); shouldBeEqualToString('selectedValue()', '2000-01-02'); @@ -46,7 +46,7 @@ function test1() { shouldBeEqualToString('selectedDayCells()', ''); shouldBeEqualToString('highlightedValue()', '1999-12-19'); shouldBeEqualToString('highlightedDayCells()', '1999-12-19'); - + debug('press down'); eventSender.keyDown('downArrow'); shouldBeEqualToString('currentMonth()', '1999-12'); @@ -254,7 +254,7 @@ function test2AfterClosing() { function testToday() { eventSender.keyDown('t'); - shouldBeTrue('isCalendarTableScrollingWithAnimation()', true /* quiet */); + shouldBeTrue('isCalendarTableScrollingWithAnimation()'); var now = new Date(); var expectedDate = serializeDate(now.getFullYear(), now.getMonth(), now.getDate()); var expectedMonth = (new popupWindow.Month(now.getFullYear(), now.getMonth())).toString(); diff --git a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-picker-key-operations.html b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-picker-key-operations.html index 4d5cf41..54d7dbb 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-picker-key-operations.html +++ b/third_party/WebKit/LayoutTests/fast/forms/calendar-picker/month-picker-key-operations.html @@ -47,7 +47,7 @@ function test1() { shouldBeEqualToString('selectedDayCells()', '2000-01-01,2000-01-02,2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09,2000-01-10,2000-01-11,2000-01-12,2000-01-13,2000-01-14,2000-01-15,2000-01-16,2000-01-17,2000-01-18,2000-01-19,2000-01-20,2000-01-21,2000-01-22,2000-01-23,2000-01-24,2000-01-25,2000-01-26,2000-01-27,2000-01-28,2000-01-29,2000-01-30,2000-01-31'); shouldBeEqualToString('highlightedValue()', '2000-01'); shouldBeEqualToString('highlightedDayCells()', '2000-01-01,2000-01-02,2000-01-03,2000-01-04,2000-01-05,2000-01-06,2000-01-07,2000-01-08,2000-01-09,2000-01-10,2000-01-11,2000-01-12,2000-01-13,2000-01-14,2000-01-15,2000-01-16,2000-01-17,2000-01-18,2000-01-19,2000-01-20,2000-01-21,2000-01-22,2000-01-23,2000-01-24,2000-01-25,2000-01-26,2000-01-27,2000-01-28,2000-01-29,2000-01-30,2000-01-31'); - + debug("press down"); eventSender.keyDown('downArrow'); shouldBeTrue('isCalendarTableScrollingWithAnimation()'); @@ -239,7 +239,7 @@ function test2AfterClosing() { function testToday() { eventSender.keyDown('t'); - shouldBeTrue('isCalendarTableScrollingWithAnimation()', true /* quiet */); + shouldBeTrue('isCalendarTableScrollingWithAnimation()'); var now = new Date(); var expectedMonth = new popupWindow.Month(now.getFullYear(), now.getMonth()).toString(); return selectedValue() === expectedMonth && highlightedValue() === expectedMonth && currentMonth() === expectedMonth; diff --git a/third_party/WebKit/LayoutTests/fast/forms/resources/multiple-fields-validity-badinput.js b/third_party/WebKit/LayoutTests/fast/forms/resources/multiple-fields-validity-badinput.js index 7f7a2ea..5796687 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/resources/multiple-fields-validity-badinput.js +++ b/third_party/WebKit/LayoutTests/fast/forms/resources/multiple-fields-validity-badinput.js @@ -34,7 +34,7 @@ function testBadInput(type) { else input.value = '2012-02-01T03:04'; shouldNotBe('colorOf(input)', 'invalidStyleColor', quiet); - shouldBeFalse('input.validity.badInput', quiet); + shouldBeFalse('input.validity.badInput'); eventSender.keyDown('rightArrow'); // -> 02/[01]/2012 ... eventSender.keyDown('downArrow'); // -> 02/[31]/2012 ... shouldBeEqualToString('input.value', ''); diff --git a/third_party/WebKit/LayoutTests/fast/harness/internals-observe-gc.html b/third_party/WebKit/LayoutTests/fast/harness/internals-observe-gc.html index 45c0013..8034977 100644 --- a/third_party/WebKit/LayoutTests/fast/harness/internals-observe-gc.html +++ b/third_party/WebKit/LayoutTests/fast/harness/internals-observe-gc.html @@ -12,8 +12,8 @@ shouldBe('typeof window.internals.observeGC', '"function"', var valueA = {}; observationA = internals.observeGC(valueA); gc(); -shouldBeFalse('observationA.wasCollected', - 'value ineligible for GC should not be flagged as collected'); +shouldBeFalse('observationA.wasCollected'); +// value ineligible for GC should not be flagged as collected valueA = null; observationA = null; @@ -23,8 +23,8 @@ var valueB = {}; observationB = internals.observeGC(valueB); valueB = null; gc(); -shouldBeTrue('observationB.wasCollected', - 'value eligible for GC should be flagged as collected'); +shouldBeTrue('observationB.wasCollected'); +// value eligible for GC should be flagged as collected observationB = null; // "One DOM Tree Hill": A family struggles with the loss of @@ -34,8 +34,8 @@ var valueC = document.createElement('div'); observationC = internals.observeGC(valueC); valueC = null; gc(); -shouldBeTrue('observationC.wasCollected', - 'DOM node eligible for GC should be flagged as collected'); +shouldBeTrue('observationC.wasCollected'); +// DOM node eligible for GC should be flagged as collected observationC = null; // Now, movies that failed: diff --git a/third_party/WebKit/LayoutTests/fast/js/webidl-type-mapping-expected.txt b/third_party/WebKit/LayoutTests/fast/js/webidl-type-mapping-expected.txt index 7f703f7..fe9e7b6 100644 --- a/third_party/WebKit/LayoutTests/fast/js/webidl-type-mapping-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/js/webidl-type-mapping-expected.txt @@ -5,8 +5,6 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE converter = window.internals.typeConversions() -PASS 'testLong' in converter is true -PASS typeof converter.testLong === 'number' is true converter.testLong = 0 PASS converter.testLong is 0 converter.testLong = -0 @@ -81,8 +79,6 @@ converter.testLong = undefined PASS converter.testLong is 0 PASS converter.testLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeLong' in converter is true -PASS typeof converter.testEnforceRangeLong === 'number' is true converter.testEnforceRangeLong = 0 PASS converter.testEnforceRangeLong is 0 converter.testEnforceRangeLong = -0 @@ -146,8 +142,6 @@ PASS converter.testEnforceRangeLong is 0 PASS converter.testEnforceRangeLong = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testUnsignedLong' in converter is true -PASS typeof converter.testUnsignedLong === 'number' is true converter.testUnsignedLong = 0 PASS converter.testUnsignedLong is 0 converter.testUnsignedLong = -0 @@ -222,8 +216,6 @@ converter.testUnsignedLong = undefined PASS converter.testUnsignedLong is 0 PASS converter.testUnsignedLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeUnsignedLong' in converter is true -PASS typeof converter.testEnforceRangeUnsignedLong === 'number' is true converter.testEnforceRangeUnsignedLong = 0 PASS converter.testEnforceRangeUnsignedLong is 0 converter.testEnforceRangeUnsignedLong = -0 @@ -282,8 +274,6 @@ PASS converter.testEnforceRangeUnsignedLong is 0 PASS converter.testEnforceRangeUnsignedLong = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeUnsignedLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testLongLong' in converter is true -PASS typeof converter.testLongLong === 'number' is true converter.testLongLong = 0 PASS converter.testLongLong is 0 converter.testLongLong = -0 @@ -358,8 +348,6 @@ converter.testLongLong = undefined PASS converter.testLongLong is 0 PASS converter.testLongLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeLongLong' in converter is true -PASS typeof converter.testEnforceRangeLongLong === 'number' is true converter.testEnforceRangeLongLong = 0 PASS converter.testEnforceRangeLongLong is 0 converter.testEnforceRangeLongLong = -0 @@ -426,8 +414,6 @@ PASS converter.testEnforceRangeLongLong is 0 PASS converter.testEnforceRangeLongLong = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeLongLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testUnsignedLongLong' in converter is true -PASS typeof converter.testUnsignedLongLong === 'number' is true converter.testUnsignedLongLong = 0 PASS converter.testUnsignedLongLong is 0 converter.testUnsignedLongLong = -0 @@ -502,8 +488,6 @@ converter.testUnsignedLongLong = undefined PASS converter.testUnsignedLongLong is 0 PASS converter.testUnsignedLongLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeUnsignedLongLong' in converter is true -PASS typeof converter.testEnforceRangeUnsignedLongLong === 'number' is true converter.testEnforceRangeUnsignedLongLong = 0 PASS converter.testEnforceRangeUnsignedLongLong is 0 converter.testEnforceRangeUnsignedLongLong = -0 @@ -562,8 +546,6 @@ PASS converter.testEnforceRangeUnsignedLongLong is 0 PASS converter.testEnforceRangeUnsignedLongLong = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeUnsignedLongLong = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testByte' in converter is true -PASS typeof converter.testByte === 'number' is true converter.testByte = 0 PASS converter.testByte is 0 converter.testByte = -0 @@ -622,8 +604,6 @@ converter.testByte = undefined PASS converter.testByte is 0 PASS converter.testByte = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeByte' in converter is true -PASS typeof converter.testEnforceRangeByte === 'number' is true converter.testEnforceRangeByte = 0 PASS converter.testEnforceRangeByte is 0 converter.testEnforceRangeByte = -0 @@ -669,8 +649,6 @@ PASS converter.testEnforceRangeByte is 0 PASS converter.testEnforceRangeByte = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeByte = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testOctet' in converter is true -PASS typeof converter.testOctet === 'number' is true converter.testOctet = 0 PASS converter.testOctet is 0 converter.testOctet = -0 @@ -733,8 +711,6 @@ converter.testOctet = undefined PASS converter.testOctet is 0 PASS converter.testOctet = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeOctet' in converter is true -PASS typeof converter.testEnforceRangeOctet === 'number' is true converter.testEnforceRangeOctet = 0 PASS converter.testEnforceRangeOctet is 0 converter.testEnforceRangeOctet = -0 @@ -780,8 +756,6 @@ PASS converter.testEnforceRangeOctet is 0 PASS converter.testEnforceRangeOctet = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeOctet = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testShort' in converter is true -PASS typeof converter.testShort === 'number' is true converter.testShort = 0 PASS converter.testShort is 0 converter.testShort = -0 @@ -846,8 +820,6 @@ converter.testShort = undefined PASS converter.testShort is 0 PASS converter.testShort = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeShort' in converter is true -PASS typeof converter.testEnforceRangeShort === 'number' is true converter.testEnforceRangeShort = 0 PASS converter.testEnforceRangeShort is 0 converter.testEnforceRangeShort = -0 @@ -901,8 +873,6 @@ PASS converter.testEnforceRangeShort is 0 PASS converter.testEnforceRangeShort = undefined threw exception TypeError: Type error. PASS converter.testEnforceRangeShort = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testUnsignedShort' in converter is true -PASS typeof converter.testUnsignedShort === 'number' is true converter.testUnsignedShort = 0 PASS converter.testUnsignedShort is 0 converter.testUnsignedShort = -0 @@ -969,8 +939,6 @@ converter.testUnsignedShort = undefined PASS converter.testUnsignedShort is 0 PASS converter.testUnsignedShort = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom. -PASS 'testEnforceRangeUnsignedShort' in converter is true -PASS typeof converter.testEnforceRangeUnsignedShort === 'number' is true converter.testEnforceRangeUnsignedShort = 0 PASS converter.testEnforceRangeUnsignedShort is 0 converter.testEnforceRangeUnsignedShort = -0 diff --git a/third_party/WebKit/LayoutTests/resources/js-test.js b/third_party/WebKit/LayoutTests/resources/js-test.js index 5909e86..fc1403f 100644 --- a/third_party/WebKit/LayoutTests/resources/js-test.js +++ b/third_party/WebKit/LayoutTests/resources/js-test.js @@ -137,13 +137,13 @@ function testFailed(msg) debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>'); } -function areArraysEqual(_a, _b) +function areArraysEqual(a, b) { try { - if (_a.length !== _b.length) + if (a.length !== b.length) return false; - for (var i = 0; i < _a.length; i++) - if (_a[i] !== _b[i]) + for (var i = 0; i < a.length; i++) + if (a[i] !== b[i]) return false; } catch (ex) { return false; @@ -158,16 +158,16 @@ function isMinusZero(n) return n === 0 && 1/n < 0; } -function isResultCorrect(_actual, _expected) +function isResultCorrect(actual, expected) { - if (_expected === 0) - return _actual === _expected && (1/_actual) === (1/_expected); - if (_actual === _expected) + if (expected === 0) + return actual === expected && (1/actual) === (1/expected); + if (actual === expected) return true; - if (typeof(_expected) == "number" && isNaN(_expected)) - return typeof(_actual) == "number" && isNaN(_actual); - if (_expected && (Object.prototype.toString.call(_expected) == Object.prototype.toString.call([]))) - return areArraysEqual(_actual, _expected); + if (typeof(expected) == "number" && isNaN(expected)) + return typeof(actual) == "number" && isNaN(actual); + if (expected && (Object.prototype.toString.call(expected) == Object.prototype.toString.call([]))) + return areArraysEqual(actual, expected); return false; } @@ -200,17 +200,17 @@ function shouldBe(_a, _b, quiet) { if (typeof _a != "string" || typeof _b != "string") debug("WARN: shouldBe() expects string arguments"); - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } var _bv = eval(_b); - if (exception) - testFailed(_a + " should be " + _bv + ". Threw exception " + exception); + if (_exception) + testFailed(_a + " should be " + _bv + ". Threw exception " + _exception); else if (isResultCorrect(_av, _bv)) { if (!quiet) { testPassed(_a + " is " + _b); @@ -234,38 +234,38 @@ function _waitForCondition(condition, failureTime, completionHandler, failureHan } } -function shouldBecomeEqual(_a, _b, completionHandler, timeout) +function shouldBecomeEqual(_a, _b, _completionHandler, _timeout) { if (typeof _a != "string" || typeof _b != "string") debug("WARN: shouldBecomeEqual() expects string arguments"); - if (timeout === undefined) - timeout = 500; + if (_timeout === undefined) + _timeout = 500; var _bv; - var condition = function() { - var exception; + var _condition = function() { + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } _bv = eval(_b); - if (exception) - testFailed(_a + " should become " + _bv + ". Threw exception " + exception); + if (_exception) + testFailed(_a + " should become " + _bv + ". Threw exception " + _exception); if (isResultCorrect(_av, _bv)) { testPassed(_a + " became " + _b); return true; } return false; }; - var failureTime = Date.now() + timeout; - var failureHandler = function () { - testFailed(_a + " failed to change to " + _bv + " in " + (timeout / 1000) + " seconds."); - completionHandler(); + var _failureTime = Date.now() + _timeout; + var _failureHandler = function () { + testFailed(_a + " failed to change to " + _bv + " in " + (_timeout / 1000) + " seconds."); + _completionHandler(); }; - _waitForCondition(condition, failureTime, completionHandler, failureHandler); + _waitForCondition(_condition, _failureTime, _completionHandler, _failureHandler); } function shouldBecomeEqualToString(value, reference, completionHandler, timeout) @@ -277,12 +277,12 @@ function shouldBecomeEqualToString(value, reference, completionHandler, timeout) } function shouldBeType(_a, _type) { - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } var _typev = eval(_type); @@ -295,7 +295,7 @@ function shouldBeType(_a, _type) { // Variant of shouldBe()--confirms that result of eval(_to_eval) is within // numeric _tolerance of numeric _target. -function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet) +function shouldBeCloseTo(_to_eval, _target, _tolerance, _quiet) { if (typeof _to_eval != "string") { testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval); @@ -323,7 +323,7 @@ function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet) testFailed(_to_eval + " should be of type " + typeof _target + " but was of type " + typeof _result); } else if (Math.abs(_result - _target) <= _tolerance) { - if (!quiet) { + if (!_quiet) { testPassed(_to_eval + " is within " + _tolerance + " of " + _target); } } else { @@ -332,68 +332,68 @@ function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet) } } -function shouldNotBe(_a, _b, quiet) +function shouldNotBe(_a, _b, _quiet) { if (typeof _a != "string" || typeof _b != "string") debug("WARN: shouldNotBe() expects string arguments"); - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } var _bv = eval(_b); - if (exception) - testFailed(_a + " should not be " + _bv + ". Threw exception " + exception); + if (_exception) + testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception); else if (!isResultCorrect(_av, _bv)) { - if (!quiet) { + if (!_quiet) { testPassed(_a + " is not " + _b); } } else testFailed(_a + " should not be " + _bv + "."); } -function shouldBecomeDifferent(_a, _b, completionHandler, timeout) +function shouldBecomeDifferent(_a, _b, _completionHandler, _timeout) { if (typeof _a != "string" || typeof _b != "string") debug("WARN: shouldBecomeDifferent() expects string arguments"); - if (timeout === undefined) - timeout = 500; + if (_timeout === undefined) + _timeout = 500; var _bv; - var condition = function() { - var exception; + var _condition = function() { + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } _bv = eval(_b); - if (exception) - testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception); + if (_exception) + testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + _exception); if (!isResultCorrect(_av, _bv)) { testPassed(_a + " became different from " + _b); return true; } return false; }; - var failureTime = Date.now() + timeout; - var failureHandler = function () { - testFailed(_a + " did not become different from " + _bv + " in " + (timeout / 1000) + " seconds."); - completionHandler(); + var _failureTime = Date.now() + _timeout; + var _failureHandler = function () { + testFailed(_a + " did not become different from " + _bv + " in " + (_timeout / 1000) + " seconds."); + _completionHandler(); }; - _waitForCondition(condition, failureTime, completionHandler, failureHandler); + _waitForCondition(_condition, _failureTime, _completionHandler, _failureHandler); } -function shouldBeTrue(_a) { shouldBe(_a, "true"); } -function shouldBeTrueQuiet(_a) { shouldBe(_a, "true", true); } -function shouldBeFalse(_a) { shouldBe(_a, "false"); } -function shouldBeNaN(_a) { shouldBe(_a, "NaN"); } -function shouldBeNull(_a) { shouldBe(_a, "null"); } -function shouldBeZero(_a) { shouldBe(_a, "0"); } +function shouldBeTrue(a, quiet) { shouldBe(a, "true", quiet); } +function shouldBeTrueQuiet(a) { shouldBe(a, "true", true); } +function shouldBeFalse(a, quiet) { shouldBe(a, "false", quiet); } +function shouldBeNaN(a, quiet) { shouldBe(a, "NaN", quiet); } +function shouldBeNull(a, quiet) { shouldBe(a, "null", quiet); } +function shouldBeZero(a, quiet) { shouldBe(a, "0", quiet); } function shouldBeEqualToString(a, b) { @@ -403,7 +403,7 @@ function shouldBeEqualToString(a, b) shouldBe(a, unevaledString); } -function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); } +function shouldBeEmptyString(a) { shouldBeEqualToString(a, ""); } function shouldEvaluateTo(actual, expected) { // A general-purpose comparator. 'actual' should be a string to be @@ -417,7 +417,7 @@ function shouldEvaluateTo(actual, expected) { } else if (typeof expected == "function") { // All this fuss is to avoid the string-arg warning from shouldBe(). try { - actualValue = eval(actual); + var actualValue = eval(actual); } catch (e) { testFailed("Evaluating " + actual + ": Threw exception " + e); return; @@ -444,16 +444,16 @@ function shouldEvaluateTo(actual, expected) { function shouldBeNonZero(_a) { - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } - if (exception) - testFailed(_a + " should be non-zero. Threw exception " + exception); + if (_exception) + testFailed(_a + " should be non-zero. Threw exception " + _exception); else if (_av != 0) testPassed(_a + " is non-zero."); else @@ -462,16 +462,16 @@ function shouldBeNonZero(_a) function shouldBeNonNull(_a) { - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } - if (exception) - testFailed(_a + " should be non-null. Threw exception " + exception); + if (_exception) + testFailed(_a + " should be non-null. Threw exception " + _exception); else if (_av != null) testPassed(_a + " is non-null."); else @@ -480,16 +480,16 @@ function shouldBeNonNull(_a) function shouldBeUndefined(_a) { - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } - if (exception) - testFailed(_a + " should be undefined. Threw exception " + exception); + if (_exception) + testFailed(_a + " should be undefined. Threw exception " + _exception); else if (typeof _av == "undefined") testPassed(_a + " is undefined."); else @@ -498,16 +498,16 @@ function shouldBeUndefined(_a) function shouldBeDefined(_a) { - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } - if (exception) - testFailed(_a + " should be defined. Threw exception " + exception); + if (_exception) + testFailed(_a + " should be defined. Threw exception " + _exception); else if (_av !== undefined) testPassed(_a + " is defined."); else @@ -518,17 +518,17 @@ function shouldBeGreaterThanOrEqual(_a, _b) { if (typeof _a != "string" || typeof _b != "string") debug("WARN: shouldBeGreaterThanOrEqual expects string arguments"); - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } var _bv = eval(_b); - if (exception) - testFailed(_a + " should be >= " + _b + ". Threw exception " + exception); + if (_exception) + testFailed(_a + " should be >= " + _b + ". Threw exception " + _exception); else if (typeof _av == "undefined" || _av < _bv) testFailed(_a + " should be >= " + _b + ". Was " + _av + " (of type " + typeof _av + ")."); else @@ -546,23 +546,23 @@ function shouldNotThrow(_a) { function shouldThrow(_a, _e) { - var exception; + var _exception; var _av; try { _av = eval(_a); } catch (e) { - exception = e; + _exception = e; } var _ev; if (_e) - _ev = eval(_e); + _ev = eval(_e); - if (exception) { - if (typeof _e == "undefined" || exception == _ev) - testPassed(_a + " threw exception " + exception + "."); + if (_exception) { + if (typeof _e == "undefined" || _exception == _ev) + testPassed(_a + " threw exception " + _exception + "."); else - testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + "."); + testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + _exception + "."); } else if (typeof _av == "undefined") testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined."); else @@ -610,7 +610,7 @@ function gc() { gcRec(n-1); }; for (var i = 0; i < 1000; i++) - gcRec(10) + gcRec(10); } } @@ -671,7 +671,7 @@ function startWorker(testScriptURL, shared) { debug('Got error from worker: ' + event.message); finishJSTest(); - } + }; if (shared) { worker.port.onmessage = function(event) { worker.onmessage(event); }; @@ -707,17 +707,17 @@ if (isWorker()) { } description = function(msg, quiet) { workerPort.postMessage('DESC:' + msg); - } + }; testFailed = function(msg) { workerPort.postMessage('FAIL:' + msg); - } + }; testPassed = function(msg) { workerPort.postMessage('PASS:' + msg); - } + }; finishJSTest = function() { workerPort.postMessage('DONE:'); - } + }; debug = function(msg) { workerPort.postMessage(msg); - } + }; } |