haikuwebkit/LayoutTests/resources/standalone-pre.js

372 lines
10 KiB
JavaScript
Raw Permalink Normal View History

var wasPostTestScriptParsed = false;
var errorMessage;
var self = this;
self.testRunner = {
neverInlineFunction: neverInlineFunction,
REGRESSION (r179357-r179359): WebContent Crash using AOL Mail @ com.apple.JavascriptCore JSC::linkPolymorphicCall(JSC::ExecState*, JSC::CallLinkInfo&, JSC::CallVariant, JSC::RegisterPreservationMode) + 1584 https://bugs.webkit.org/show_bug.cgi?id=150513 Reviewed by Saam Barati. Source/JavaScriptCore: Add check in linkPolymorphicCall() to make sure we have a CodeBlock for the newly added variant. If not, we turn the call into a virtual call. The bug was caused by a stack overflow when preparing the function for execution. This properly threw an exception, however linkPolymorphicCall() didn't check for this error case. Added a new test function "failNextNewCodeBlock()" to test tools to simplify the testing. * API/JSCTestRunnerUtils.cpp: (JSC::failNextNewCodeBlock): (JSC::numberOfDFGCompiles): * API/JSCTestRunnerUtils.h: * jit/Repatch.cpp: (JSC::linkPolymorphicCall): * jsc.cpp: (GlobalObject::finishCreation): (functionTransferArrayBuffer): (functionFailNextNewCodeBlock): (functionQuit): * runtime/Executable.cpp: (JSC::ScriptExecutable::prepareForExecutionImpl): * runtime/TestRunnerUtils.cpp: (JSC::optimizeNextInvocation): (JSC::failNextNewCodeBlock): (JSC::numberOfDFGCompiles): * runtime/TestRunnerUtils.h: * runtime/VM.h: (JSC::VM::setFailNextNewCodeBlock): (JSC::VM::getAndClearFailNextNewCodeBlock): (JSC::VM::stackPointerAtVMEntry): Tools: Added a new test function, failNextNewCodeBlock() to simplify the writing of a regression test. * DumpRenderTree/TestRunner.cpp: (simulateWebNotificationClickCallback): (failNextCodeBlock): (numberOfDFGCompiles): (TestRunner::staticFunctions): * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::setBlockAllPlugins): (WTR::TestRunner::failNextCodeBlock): (WTR::TestRunner::numberOfDFGCompiles): * WebKitTestRunner/InjectedBundle/TestRunner.h: LayoutTests: New regression test. * js/regress-150513-expected.txt: Added. * js/regress-150513.html: Added. * js/script-tests/regress-150513.js: Added. (test): * resources/standalone-pre.js: Added failNextNewCodeBlock to testRunner object. Canonical link: https://commits.webkit.org/168677@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-10-24 01:45:30 +00:00
numberOfDFGCompiles: numberOfDFGCompiles,
failNextNewCodeBlock: failNextNewCodeBlock
};
var silentTestPass, didPassSomeTestsSilently, didFailSomeTests, successfullyParsed;
silentTestPass = false;
didPassSomeTestsSilently = false;
didFailSomeTests = false;
function description(msg)
{
print(msg);
print("\nOn success, you will see a series of \"PASS\" messages, followed by \"TEST COMPLETE\".\n");
print();
}
function debug(msg)
{
print(msg);
}
function escapeString(text)
{
return text.replace(/\0/g, "");
}
function testPassed(msg)
{
if (silentTestPass)
didPassSomeTestsSilently = true;
else
print("PASS", escapeString(msg));
}
function testFailed(msg)
{
didFailSomeTests = true;
print("FAIL", escapeString(msg));
}
function areNumbersEqual(_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);
return false;
}
function areArraysEqual(_a, _b)
{
try {
if (_a.length !== _b.length)
return false;
for (var i = 0; i < _a.length; i++)
if (!areNumbersEqual(_a[i], _b[i]))
return false;
} catch (ex) {
return false;
}
return true;
}
function isMinusZero(n)
{
// the only way to tell 0 from -0 in JS is the fact that 1/-0 is
// -Infinity instead of Infinity
return n === 0 && 1/n < 0;
}
function isTypedArray(array)
{
return array instanceof Int8Array
|| array instanceof Int16Array
|| array instanceof Int32Array
|| array instanceof Uint8Array
|| array instanceof Uint8ClampedArray
|| array instanceof Uint16Array
|| array instanceof Uint32Array
|| array instanceof Float32Array
|| array instanceof Float64Array;
}
function isResultCorrect(_actual, _expected)
{
if (areNumbersEqual(_actual, _expected))
return true;
if (_expected
&& (Object.prototype.toString.call(_expected) ==
Object.prototype.toString.call([])
|| isTypedArray(_expected)))
return areArraysEqual(_actual, _expected);
return false;
}
function stringify(v)
{
if (v === 0 && 1/v < 0)
return "-0";
else if (isTypedArray(v))
return v.__proto__.constructor.name + ":[" + Array.prototype.join.call(v, ",") + "]";
else
return "" + v;
}
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
function shouldBe(_a, _b, _quiet)
{
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
debug("WARN: shouldBe() expects function or string arguments");
var _exception;
var _av;
try {
_av = (typeof _a == "function" ? _a() : eval(_a));
} catch (e) {
_exception = e;
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
}
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
var _bv = (typeof _b == "function" ? _b() : eval(_b));
if (_exception)
testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + _exception);
else if (isResultCorrect(_av, _bv)) {
if (!_quiet) {
testPassed(_a + " is " + (typeof _b == "function" ? _bv : _b));
}
} else if (typeof(_av) == typeof(_bv))
testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
else
testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
}
function dfgShouldBe(theFunction, _a, _b)
{
if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
debug("WARN: dfgShouldBe() expects a function and two strings");
noInline(theFunction);
var exception;
var values = [];
// Defend against tests that muck with numeric properties on array.prototype.
values.__proto__ = null;
values.push = Array.prototype.push;
try {
while (!dfgCompiled({f:theFunction}))
values.push(eval(_a));
values.push(eval(_a));
} catch (e) {
exception = e;
}
var _bv = eval(_b);
if (exception)
testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
else {
var allPassed = true;
for (var i = 0; i < values.length; ++i) {
var _av = values[i];
if (isResultCorrect(_av, _bv))
continue;
if (typeof(_av) == typeof(_bv))
testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
else
testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
allPassed = false;
}
if (allPassed)
testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
}
return values.length;
}
function shouldBeType(_a, _type) {
var exception;
var _av;
try {
_av = eval(_a);
} catch (e) {
exception = e;
}
var _typev = eval(_type);
if (_av instanceof _typev) {
testPassed(_a + " is an instance of " + _type);
} else {
testFailed(_a + " is not an instance of " + _type);
}
}
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
function shouldNotBe(_a, _b, _quiet)
{
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
if ((typeof _a != "function" && typeof _a != "string") || (typeof _b != "function" && typeof _b != "string"))
debug("WARN: shouldNotBe() expects function or string arguments");
var _exception;
var _av;
try {
_av = (typeof _a == "function" ? _a() : eval(_a));
} catch (e) {
_exception = e;
}
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
var _bv = (typeof _b == "function" ? _b() : eval(_b));
if (_exception)
testFailed(_a + " should not be " + _bv + ". Threw exception " + _exception);
else if (!isResultCorrect(_av, _bv)) {
if (!_quiet) {
testPassed(_a + " is not " + (typeof _b == "function" ? _bv : _b));
}
} else
testFailed(_a + " should not be " + _bv + ".");
}
function shouldBeTrue(_a) { shouldBe(_a, "true"); }
function shouldBeFalse(_a) { shouldBe(_a, "false"); }
function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
function shouldBeNull(_a) { shouldBe(_a, "null"); }
function shouldBeEqualToString(a, b)
{
if (typeof a !== "string" || typeof b !== "string")
debug("WARN: shouldBeEqualToString() expects string arguments");
var unevaledString = JSON.stringify(b);
shouldBe(a, unevaledString);
}
function shouldBeUndefined(_a)
{
var exception;
var _av;
try {
_av = eval(_a);
} catch (e) {
exception = e;
}
if (exception)
testFailed(_a + " should be undefined. Threw exception " + exception);
else if (typeof _av == "undefined")
testPassed(_a + " is undefined.");
else
testFailed(_a + " should be undefined. Was " + _av);
}
function shouldBeDefined(_a)
{
var exception;
var _av;
try {
_av = eval(_a);
} catch (e) {
exception = e;
}
if (exception)
testFailed(_a + " should be defined. Threw exception " + exception);
else if (_av !== undefined)
testPassed(_a + " is defined.");
else
testFailed(_a + " should be defined. Was " + _av);
}
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
function shouldNotThrow(_a, _message) {
try {
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
typeof _a == "function" ? _a() : eval(_a);
testPassed((_message ? _message : _a) + " did not throw exception.");
} catch (e) {
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
testFailed((_message ? _message : _a) + " should not throw exception. Threw exception " + e + ".");
}
}
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
function shouldThrow(_a, _e, _message)
{
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
var _exception;
var _av;
try {
_av = typeof _a == "function" ? _a() : eval(_a);
} catch (e) {
_exception = e;
}
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
var _ev;
if (_e)
check-webkit-style should keep JavaScript test functions in sync <https://webkit.org/b/171424> Reviewed by Joseph Pecoraro. JSTests: This change makes shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() in sync with other copies of these methods. * stress/resources/standalone-pre.js: (shouldBe): Fix whitespace. Prefix 'exception' and 'quiet' variables with underscore. (shouldThrow): Fix whitespace. Tools: Add a new JSTestChecker for check-webkit-style that keeps these two files in sync: LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js And keeps implementations of shouldBe(), shouldNotBe(), shouldNotThrow(), and shouldThrow() in sync across multiple files (with the ability to add more functions later): JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js * Scripts/webkitpy/style/checker.py: Remove unused import. Add import for JSTestChecker. (_NEVER_SKIPPED_FILES): Add array of file names that are never skipped regardless of other rules. (_all_categories): Add JSTestChecker categories. (CheckerDispatcher.should_skip_without_warning): Use _NEVER_SKIPPED_FILES. (CheckerDispatcher._create_checker): Return JSTestChecker for the files to check. * Scripts/webkitpy/style/checkers/jstest.py: Add. (map_functions_to_dict): Parse JavaScript source by splitting on /^function\s+/ regex. This is good enough for the sanity checks to keep function implementations in sync. (strip_blank_lines_and_comments): Strips blank lines and lines with comments from the end of a chunk of text representing a function. (JSTestChecker): New checker. (JSTestChecker.__init__): (JSTestChecker.check): (JSTestChecker.check_js_test_files): Keeps whole files in sync. (JSTestChecker.check_js_test_functions): Keeps individual functions in sync. * Scripts/webkitpy/style/checkers/jstest_unittest.py: Add test case. (JSTestTestCase): (JSTestTestCase.test_map_functions_to_dict): LayoutTests: This change attempts to fix all whitespace issues in these two files (which are now identical and will be kept in sync by check-webkit-style): LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js It also syncs the implementation of shouldBe(), shouldNotBe(), shouldNotThrow() and shouldThrow() across the following files: JSTests/stress/resources/standalone-pre.js LayoutTests/http/tests/resources/js-test-pre.js LayoutTests/resources/js-test-pre.js LayoutTests/resources/js-test.js LayoutTests/resources/standalone-pre.js Only interesting (non-whitespace) changes are listed below. * http/tests/resources/js-test-pre.js: Copy from resources/js-test-pre.js. (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. * resources/js-test.js: (shouldBe): Prefix 'quiet' variable with underscore. Use stringify() when printing '_bv' value. * resources/standalone-pre.js: (shouldBe): Prefix 'exception' and 'quiet' variables with underscore. (shouldNotBe): Ditto. Canonical link: https://commits.webkit.org/188477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-02 20:10:12 +00:00
_ev = eval(_e);
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
if (_exception) {
if (typeof _e == "undefined" || _exception == _ev)
testPassed((_message ? _message : _a) + " threw exception " + _exception + ".");
else
testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + _exception + ".");
} else if (typeof _av == "undefined")
testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined.");
else
Enhance shouldBe()/shouldNotBe() to accept anonymous function arguments <https://webkit.org/b/171362> <rdar://problem/31867686> Reviewed by Joseph Pecoraro. JSTests: * stress/resources/standalone-pre.js: (shouldBe): (shouldNotThrow): (shouldThrow): - Update shouldBe() to accept anonymous function arguments. (The shouldNotBe() function was never copied over.) - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). LayoutTests: This change makes it possible to pass either the first or second argument (or both) as anonymous functions into shouldBe() and shouldNotBe() to make it easy to capture local variables when writing tests. This is similar to the change in r202609 for Bug 159232 for shouldThrow() and shouldNotThrow(). Note that shouldBe()/shouldNotBe() from the following files were NOT updated since they were imported from other projects and did share the full WebKit history of resources/js-test-pre.js: http/tests/webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js js/mozilla/resources/js-test-pre.js webgl/1.0.2/resources/webgl_test_files/resources/js-test-pre.js webgl/1.0.3/resources/webgl_test_files/resources/js-test-pre.js However, these files WERE brought up-to-date with the ability to pass anonymous functions into shouldBe()/shouldNotBe() for this bug, and shouldThrow()/shouldNotThrow() which should have originally been fixed with Bug 159232: http/tests/resources/js-test-pre.js resources/standalone-pre.js * css3/scroll-snap/resources/iframe-content.html: Drive-by fix to debug message for copy-paste error. Found by searching LayoutTests directory for "expects string arguments". * fast/canvas/webgl/array-unit-tests-expected.txt: Update test results. * fast/canvas/webgl/array-unit-tests.html: Fix warning by making second argument to shouldBe() a string. * fast/css/script-tests/image-set-parsing.js: (testImageSetRule): Remove comment by changing second argument to shouldBe() into an anonymous function. * http/tests/resources/js-test-pre.js: (evalAndLog): (evalAndLogResult): (shouldBe): (shouldNotBe): (shouldEvaluateTo): - Made a full copy of resources/js-test-pre.js to bring this up to speed. Needs a checker written for it to keep them in sync. * http/tests/security/xssAuditor/block-does-not-leak-location-expected.txt: * http/tests/security/xssAuditor/block-does-not-leak-referrer-expected.txt: - Update line numbers after updating http/tests/resources/js-test-pre.js. * js/function-declarations-in-switch-statement-expected.txt: - Update results after fixing warnings. * js/script-tests/function-declarations-in-switch-statement.js: - Fix warnings by passing in strings to shouldBe(). * js/script-tests/stack-unwinding.js: - Update results after fixing warnings. * js/stack-unwinding-expected.txt: - Fix warnings by passing in strings to shouldBe(). * resources/js-test-pre.js: (shouldBe): (shouldNotBe): * resources/js-test.js: (shouldBe): (shouldNotBe): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. * resources/standalone-pre.js: (shouldBe): (shouldNotBe): (shouldNotThrow): (shouldThrow): - Update shouldBe()/shouldNotBe() to accept anonymous function arguments. - Also fix shouldThrow()/shouldNotThrow() to accept anonymous function arguments (which were missed in r202609 for Bug 159232). Canonical link: https://commits.webkit.org/188288@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-27 21:29:23 +00:00
testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
}
function isSuccessfullyParsed()
{
// FIXME: Remove this and only report unexpected syntax errors.
if (!errorMessage)
successfullyParsed = true;
shouldBeTrue("successfullyParsed");
if (silentTestPass && didPassSomeTestsSilently)
debug("Passed some tests silently.");
if (silentTestPass && didFailSomeTests)
debug("Some tests failed.");
debug("\nTEST COMPLETE\n");
}
function dfgCompiled(argument)
{
var numberOfCompiles = "compiles" in argument ? argument.compiles : 1;
if (!("f" in argument))
throw new Error("dfgCompiled called with invalid argument.");
if (argument.f instanceof Array) {
for (var i = 0; i < argument.f.length; ++i) {
if (testRunner.numberOfDFGCompiles(argument.f[i]) < numberOfCompiles)
return false;
}
} else {
if (testRunner.numberOfDFGCompiles(argument.f) < numberOfCompiles)
return false;
}
return true;
}
function dfgIncrement(argument)
{
if (!self.testRunner)
return argument.i;
if (argument.i < argument.n)
return argument.i;
if (didFailSomeTests)
return argument.i;
if (!dfgCompiled(argument))
return "start" in argument ? argument.start : 0;
return argument.i;
}
function noInline(theFunction)
{
if (!self.testRunner)
return;
testRunner.neverInlineFunction(theFunction);
}
// It's possible for an async test to call finishJSTest() before js-test-post.js
// has been parsed.
function finishJSTest()
{
wasFinishJSTestCalled = true;
if (!wasPostTestScriptParsed)
return;
isSuccessfullyParsed();
}