2014-02-12 18:17:47 +00:00
if ( self . testRunner ) {
2016-01-19 06:02:30 +00:00
// svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump text + pixel results
2014-02-12 18:17:47 +00:00
if ( self . enablePixelTesting )
testRunner . dumpAsTextWithPixelResults ( ) ;
else
testRunner . dumpAsText ( ) ;
}
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
var description , debug , didFailSomeTests , successfullyParsed ;
didFailSomeTests = false ;
2014-02-12 18:17:47 +00:00
var expectingError ; // set by shouldHaveError()
var expectedErrorMessage ; // set by onerror when expectingError is true
var unexpectedErrorMessage ; // set by onerror when expectingError is not true
( function ( ) {
2014-04-02 21:40:26 +00:00
function createHTMLElement ( tagName )
{
// FIXME: In an XML document, document.createElement() creates an element with a null namespace URI.
// So, we need use document.createElementNS() to explicitly create an element with the specified
// tag name in the HTML namespace. We can remove this function and use document.createElement()
// directly once we fix <https://bugs.webkit.org/show_bug.cgi?id=131074>.
if ( document . createElementNS )
return document . createElementNS ( "http://www.w3.org/1999/xhtml" , tagName ) ;
return document . createElement ( tagName ) ;
}
2017-10-25 01:35:45 +00:00
var rootElement = null ;
function ensureRootElement ( )
{
if ( ! rootElement || ! rootElement . isConnected ) {
rootElement = document . body || document . documentElement ;
if ( document . documentElement . namespaceURI == 'http://www.w3.org/2000/svg' ) {
// FIXME: Make the test harness use SVG elements naively.
var foreignObject = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'foreignObject' ) ;
foreignObject . setAttribute ( 'x' , '0px' ) ;
foreignObject . setAttribute ( 'y' , '0px' ) ;
foreignObject . setAttribute ( 'width' , '100%' ) ;
foreignObject . setAttribute ( 'height' , '100%' ) ;
foreignObject . setAttribute ( 'style' , 'padding: 10px; background-color: rgba(255, 255, 255, 0.5)' ) ;
document . documentElement . appendChild ( foreignObject ) ;
rootElement = foreignObject ;
}
}
return rootElement ;
}
moveForeignObjectToTopIfNeeded = function ( ) {
if ( rootElement && rootElement . localName == 'foreignObject' )
document . documentElement . appendChild ( rootElement ) ;
}
2014-02-12 18:17:47 +00:00
function getOrCreate ( id , tagName )
{
var element = document . getElementById ( id ) ;
if ( element )
return element ;
2014-04-02 21:40:26 +00:00
element = createHTMLElement ( tagName ) ;
2014-02-12 18:17:47 +00:00
element . id = id ;
var refNode ;
2017-10-25 01:35:45 +00:00
var parent = ensureRootElement ( ) ;
2014-02-12 18:17:47 +00:00
if ( id == "description" )
refNode = getOrCreate ( "console" , "div" ) ;
else
refNode = parent . firstChild ;
parent . insertBefore ( element , refNode ) ;
return element ;
}
description = function description ( msg , quiet )
{
// For MSIE 6 compatibility
2014-04-02 21:40:26 +00:00
var span = createHTMLElement ( "span" ) ;
2014-02-12 18:17:47 +00:00
if ( quiet )
span . innerHTML = '<p>' + msg + '</p><p>On success, you will see no "<span class="fail">FAIL</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>' ;
else
span . innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>' ;
var description = getOrCreate ( "description" , "p" ) ;
if ( description . firstChild )
description . replaceChild ( span , description . firstChild ) ;
else
description . appendChild ( span ) ;
} ;
debug = function debug ( msg )
{
2014-04-02 21:40:26 +00:00
var span = createHTMLElement ( "span" ) ;
2014-02-12 18:17:47 +00:00
span . innerHTML = msg + '<br />' ;
2017-10-25 01:35:45 +00:00
getOrCreate ( "console" , "div" ) . appendChild ( span ) ;
2014-02-12 18:17:47 +00:00
} ;
var css =
".pass {" +
"font-weight: bold;" +
"color: green;" +
"}" +
".fail {" +
"font-weight: bold;" +
"color: red;" +
"}" +
"#console {" +
"white-space: pre-wrap;" +
"font-family: monospace;" +
"}" ;
function insertStyleSheet ( )
{
2014-04-02 21:40:26 +00:00
var styleElement = createHTMLElement ( "style" ) ;
2014-02-12 18:17:47 +00:00
styleElement . textContent = css ;
2017-10-25 01:35:45 +00:00
( document . head || ensureRootElement ( ) ) . appendChild ( styleElement ) ;
2014-02-12 18:17:47 +00:00
}
function handleTestFinished ( )
{
// FIXME: Get rid of this boolean.
wasPostTestScriptParsed = true ;
if ( window . jsTestIsAsync ) {
if ( window . testRunner )
testRunner . waitUntilDone ( ) ;
if ( window . wasFinishJSTestCalled )
finishJSTest ( ) ;
} else
finishJSTest ( ) ;
}
if ( ! isWorker ( ) ) {
fast/canvas/webgl/angle-instanced-arrays.html is very flaky
https://bugs.webkit.org/show_bug.cgi?id=139958
Reviewed by Darin Adler.
WebGL test harness added js-test-post.js in a flaky manner, and to make things worse,
this test also had its own include of js-test-post.js.
Looking at the tests, I noticed that the way test harnesses were used was a big mess,
so I went over the whole directory, making these changes:
1. Use js-test.js instead of js-test-pre.js, because it's simpler and better macthes
the Khronos test model.
2. Removed js-test-post.js everywhere (some tests included it in particularly crazy ways).
3. Removed successfullyParsed = true, as js-test.js doesn't need that.
4. Updated DOCTYPE, while editing these tests anyway.
5. Tests now have correct order of lines in the output (no longer saying TEST COMPLETE
before PASS), so updated results.
6. In js-test tests, we shouldn't use waitUntilDone/notifyDone explicitly, so
updated these with jsTestIsAsync.
7. Updated async tests that used initNonKhronosFramework(false) plus some way to
become async to simply say initNonKhronosFramework(true).
8. Removed isSuccessfullyParsed() calls that several tests were using as an ugly
workaround for issues caused by misusing the harness. This is never expected to be
called directly.
* fast/canvas/webgl/angle-instanced-arrays-out-of-bounds.html:
Removed an unneeded js-test-style.css include.
* fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html:
Swapped lines to not have glErrorShouldBe after finishTest.
* fast/canvas/webgl/resources/webgl-test.js:
(initNonKhronosFramework): webgl-test.js relies on js-test anyway, so there is
no need to duplicate the work.
(nonKhronosFrameworkNotifyDone): Use the proper js-test mechanism.
(finishTest): Ditto.
(finishTest.epilogue.document.createElement.epilogue.onload): Deleted.
* resources/js-test.js:
(expectTrue): Added this function that we only has in js-test-pre.js.
(): Perform work after test's load event handler, not immediately on DOMContentLoaded.
This has two benefits:
1. Tests that enable jsTestIsAsync in onload do work. This is expected, because
tests that call waitUntilDone from onload also do work.
2. Non-async tests that perform work in onload have the correct order of lines in output.
* fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt:
* fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt:
* fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt:
* fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
* fast/hidpi/image-srcset-src-selection-1x-both-expected.txt:
* svg/custom/html_document_set_title-expected.txt:
Updated results for js-test.js improvements.
* fast/canvas/webgl/WebGLContextEvent.html:
* fast/canvas/webgl/angle-instanced-arrays.html:
* fast/canvas/webgl/array-bounds-clamping.html:
* fast/canvas/webgl/array-buffer-crash.html:
* fast/canvas/webgl/array-buffer-view-crash-when-reassigned.html:
* fast/canvas/webgl/array-buffer-view-crash.html:
* fast/canvas/webgl/array-constructor.html:
* fast/canvas/webgl/array-get-and-set-method-removal.html:
* fast/canvas/webgl/array-get-out-of-bounds.html:
* fast/canvas/webgl/array-message-passing.html:
* fast/canvas/webgl/array-override-set.html:
* fast/canvas/webgl/array-set-invalid-arguments.html:
* fast/canvas/webgl/array-set-out-of-bounds.html:
* fast/canvas/webgl/array-set-with-offset.html:
* fast/canvas/webgl/array-setters.html:
* fast/canvas/webgl/array-unit-tests.html:
* fast/canvas/webgl/arraybuffer-transfer-of-control.html:
* fast/canvas/webgl/attrib-location-length-limits.html:
* fast/canvas/webgl/bad-arguments-test.html:
* fast/canvas/webgl/buffer-bind-test.html:
* fast/canvas/webgl/buffer-data-array-buffer.html:
* fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt:
* fast/canvas/webgl/canvas-2d-webgl-texture.html:
* fast/canvas/webgl/canvas-resize-crash.html:
* fast/canvas/webgl/canvas-supports-context.html:
* fast/canvas/webgl/canvas-test.html:
* fast/canvas/webgl/canvas-zero-size.html:
* fast/canvas/webgl/compressed-tex-image.html:
* fast/canvas/webgl/constants.html:
* fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html:
* fast/canvas/webgl/context-creation-and-destruction.html:
* fast/canvas/webgl/context-lost-restored.html:
* fast/canvas/webgl/context-lost.html:
* fast/canvas/webgl/context-release-upon-reload.html:
* fast/canvas/webgl/copy-tex-image-and-sub-image-2d.html:
* fast/canvas/webgl/data-view-crash.html:
* fast/canvas/webgl/data-view-test.html:
* fast/canvas/webgl/draw-arrays-out-of-bounds.html:
* fast/canvas/webgl/draw-elements-out-of-bounds.html:
* fast/canvas/webgl/drawingbuffer-test.html:
* fast/canvas/webgl/error-reporting.html:
* fast/canvas/webgl/framebuffer-object-attachment.html:
* fast/canvas/webgl/framebuffer-test.html:
* fast/canvas/webgl/functions-returning-strings.html:
* fast/canvas/webgl/get-active-test.html:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test.html:
* fast/canvas/webgl/gl-bind-attrib-location-test.html:
* fast/canvas/webgl/gl-bind-attrib-mapped-names.html:
* fast/canvas/webgl/gl-enable-enum-test.html:
* fast/canvas/webgl/gl-enum-tests.html:
* fast/canvas/webgl/gl-get-calls.html:
* fast/canvas/webgl/gl-getshadersource.html:
* fast/canvas/webgl/gl-getstring.html:
* fast/canvas/webgl/gl-object-get-calls.html:
* fast/canvas/webgl/gl-pixelstorei.html:
* fast/canvas/webgl/gl-teximage.html:
* fast/canvas/webgl/gl-uniform-arrays.html:
* fast/canvas/webgl/gl-uniformmatrix4fv.html:
* fast/canvas/webgl/gl-vertex-attrib-zero-issues.html:
* fast/canvas/webgl/gl-vertex-attrib.html:
* fast/canvas/webgl/gl-vertexattribpointer.html:
* fast/canvas/webgl/glsl-conformance.html:
* fast/canvas/webgl/incorrect-context-object-behaviour.html:
* fast/canvas/webgl/index-validation-copies-indices.html:
* fast/canvas/webgl/index-validation-crash-with-buffer-sub-data.html:
* fast/canvas/webgl/index-validation-verifies-too-many-indices.html:
* fast/canvas/webgl/index-validation-with-resized-buffer.html:
* fast/canvas/webgl/index-validation.html:
* fast/canvas/webgl/instanceof-test.html:
* fast/canvas/webgl/invalid-UTF-16.html:
* fast/canvas/webgl/invalid-passed-params.html:
* fast/canvas/webgl/is-object.html:
* fast/canvas/webgl/null-object-behaviour.html:
* fast/canvas/webgl/null-uniform-location.html:
* fast/canvas/webgl/object-deletion-behaviour.html:
* fast/canvas/webgl/oes-element-index-uint.html:
* fast/canvas/webgl/oes-texture-float-linear-expected.txt:
* fast/canvas/webgl/oes-texture-float-linear.html:
* fast/canvas/webgl/oes-texture-half-float-linear-expected.txt:
* fast/canvas/webgl/oes-texture-half-float-linear.html:
* fast/canvas/webgl/oes-texture-half-float-with-canvas.html:
* fast/canvas/webgl/oes-texture-half-float-with-image.html:
* fast/canvas/webgl/oes-texture-half-float-with-video.html:
* fast/canvas/webgl/oes-texture-half-float.html:
* fast/canvas/webgl/oes-vertex-array-object.html:
* fast/canvas/webgl/point-size.html:
* fast/canvas/webgl/premultiplyalpha-test-expected.txt:
* fast/canvas/webgl/premultiplyalpha-test.html:
* fast/canvas/webgl/program-test.html:
* fast/canvas/webgl/read-pixels-pack-alignment.html:
* fast/canvas/webgl/read-pixels-test.html:
* fast/canvas/webgl/renderbuffer-initialization.html:
* fast/canvas/webgl/renderer-and-vendor-strings.html:
* fast/canvas/webgl/resources/tex-image-and-sub-image-2d-with-video.js:
* fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js:
* fast/canvas/webgl/shader-deleted-by-accessor.html:
* fast/canvas/webgl/shader-precision-format.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-array-buffer-view.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-potentially-subsampled-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-svg-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video.html:
* fast/canvas/webgl/tex-image-and-uniform-binding-bugs.html:
* fast/canvas/webgl/tex-image-webgl.html:
* fast/canvas/webgl/tex-image-with-format-and-type.html:
* fast/canvas/webgl/tex-image-with-greyscale-image.html:
* fast/canvas/webgl/tex-input-validation.html:
* fast/canvas/webgl/tex-sub-image-2d-bad-args.html:
* fast/canvas/webgl/tex-sub-image-2d.html:
* fast/canvas/webgl/tex-sub-image-cube-maps.html:
* fast/canvas/webgl/texImageTest.html:
* fast/canvas/webgl/texture-active-bind.html:
* fast/canvas/webgl/texture-bindings-uneffected-on-resize-expected.txt:
* fast/canvas/webgl/texture-bindings-uneffected-on-resize.html:
* fast/canvas/webgl/texture-color-profile.html:
* fast/canvas/webgl/texture-complete.html:
* fast/canvas/webgl/texture-npot.html:
* fast/canvas/webgl/texture-transparent-pixels-initialized.html:
* fast/canvas/webgl/triangle.html:
* fast/canvas/webgl/type-conversion-test.html:
* fast/canvas/webgl/typed-arrays-in-workers.html:
* fast/canvas/webgl/uniform-array-length-overflow.html:
* fast/canvas/webgl/uniform-location-length-limits.html:
* fast/canvas/webgl/uniform-location.html:
* fast/canvas/webgl/uniform-samplers-test.html:
* fast/canvas/webgl/uninitialized-test.html:
* fast/canvas/webgl/viewport-unchanged-upon-resize.html:
* fast/canvas/webgl/webgl-array-invalid-ranges.html:
* fast/canvas/webgl/webgl-compressed-texture-size-limit.html:
* fast/canvas/webgl/webgl-depth-texture-expected.txt:
* fast/canvas/webgl/webgl-depth-texture.html:
* fast/canvas/webgl/webgl-draw-buffers.html:
* fast/canvas/webgl/webgl-exceptions.html:
* fast/canvas/webgl/webgl-specific.html:
* fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt:
* fast/canvas/webgl/webgl-texture-binding-preserved.html:
* fast/canvas/webgl/webgl-unprefixed-context-id.html:
* fast/canvas/webgl/webgl-viewport-parameters-preserved-expected.txt:
* fast/canvas/webgl/webgl-viewport-parameters-preserved.html:
Canonical link: https://commits.webkit.org/157930@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-27 23:22:02 +00:00
window . addEventListener ( 'DOMContentLoaded' , function ( ) {
2017-05-24 00:27:24 +00:00
// Call waitUntilDone() as early as possible otherwise some tests may complete before
// the load event has fired.
if ( window . jsTestIsAsync && window . testRunner )
testRunner . waitUntilDone ( ) ;
fast/canvas/webgl/angle-instanced-arrays.html is very flaky
https://bugs.webkit.org/show_bug.cgi?id=139958
Reviewed by Darin Adler.
WebGL test harness added js-test-post.js in a flaky manner, and to make things worse,
this test also had its own include of js-test-post.js.
Looking at the tests, I noticed that the way test harnesses were used was a big mess,
so I went over the whole directory, making these changes:
1. Use js-test.js instead of js-test-pre.js, because it's simpler and better macthes
the Khronos test model.
2. Removed js-test-post.js everywhere (some tests included it in particularly crazy ways).
3. Removed successfullyParsed = true, as js-test.js doesn't need that.
4. Updated DOCTYPE, while editing these tests anyway.
5. Tests now have correct order of lines in the output (no longer saying TEST COMPLETE
before PASS), so updated results.
6. In js-test tests, we shouldn't use waitUntilDone/notifyDone explicitly, so
updated these with jsTestIsAsync.
7. Updated async tests that used initNonKhronosFramework(false) plus some way to
become async to simply say initNonKhronosFramework(true).
8. Removed isSuccessfullyParsed() calls that several tests were using as an ugly
workaround for issues caused by misusing the harness. This is never expected to be
called directly.
* fast/canvas/webgl/angle-instanced-arrays-out-of-bounds.html:
Removed an unneeded js-test-style.css include.
* fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html:
Swapped lines to not have glErrorShouldBe after finishTest.
* fast/canvas/webgl/resources/webgl-test.js:
(initNonKhronosFramework): webgl-test.js relies on js-test anyway, so there is
no need to duplicate the work.
(nonKhronosFrameworkNotifyDone): Use the proper js-test mechanism.
(finishTest): Ditto.
(finishTest.epilogue.document.createElement.epilogue.onload): Deleted.
* resources/js-test.js:
(expectTrue): Added this function that we only has in js-test-pre.js.
(): Perform work after test's load event handler, not immediately on DOMContentLoaded.
This has two benefits:
1. Tests that enable jsTestIsAsync in onload do work. This is expected, because
tests that call waitUntilDone from onload also do work.
2. Non-async tests that perform work in onload have the correct order of lines in output.
* fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt:
* fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt:
* fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt:
* fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
* fast/hidpi/image-srcset-src-selection-1x-both-expected.txt:
* svg/custom/html_document_set_title-expected.txt:
Updated results for js-test.js improvements.
* fast/canvas/webgl/WebGLContextEvent.html:
* fast/canvas/webgl/angle-instanced-arrays.html:
* fast/canvas/webgl/array-bounds-clamping.html:
* fast/canvas/webgl/array-buffer-crash.html:
* fast/canvas/webgl/array-buffer-view-crash-when-reassigned.html:
* fast/canvas/webgl/array-buffer-view-crash.html:
* fast/canvas/webgl/array-constructor.html:
* fast/canvas/webgl/array-get-and-set-method-removal.html:
* fast/canvas/webgl/array-get-out-of-bounds.html:
* fast/canvas/webgl/array-message-passing.html:
* fast/canvas/webgl/array-override-set.html:
* fast/canvas/webgl/array-set-invalid-arguments.html:
* fast/canvas/webgl/array-set-out-of-bounds.html:
* fast/canvas/webgl/array-set-with-offset.html:
* fast/canvas/webgl/array-setters.html:
* fast/canvas/webgl/array-unit-tests.html:
* fast/canvas/webgl/arraybuffer-transfer-of-control.html:
* fast/canvas/webgl/attrib-location-length-limits.html:
* fast/canvas/webgl/bad-arguments-test.html:
* fast/canvas/webgl/buffer-bind-test.html:
* fast/canvas/webgl/buffer-data-array-buffer.html:
* fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt:
* fast/canvas/webgl/canvas-2d-webgl-texture.html:
* fast/canvas/webgl/canvas-resize-crash.html:
* fast/canvas/webgl/canvas-supports-context.html:
* fast/canvas/webgl/canvas-test.html:
* fast/canvas/webgl/canvas-zero-size.html:
* fast/canvas/webgl/compressed-tex-image.html:
* fast/canvas/webgl/constants.html:
* fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html:
* fast/canvas/webgl/context-creation-and-destruction.html:
* fast/canvas/webgl/context-lost-restored.html:
* fast/canvas/webgl/context-lost.html:
* fast/canvas/webgl/context-release-upon-reload.html:
* fast/canvas/webgl/copy-tex-image-and-sub-image-2d.html:
* fast/canvas/webgl/data-view-crash.html:
* fast/canvas/webgl/data-view-test.html:
* fast/canvas/webgl/draw-arrays-out-of-bounds.html:
* fast/canvas/webgl/draw-elements-out-of-bounds.html:
* fast/canvas/webgl/drawingbuffer-test.html:
* fast/canvas/webgl/error-reporting.html:
* fast/canvas/webgl/framebuffer-object-attachment.html:
* fast/canvas/webgl/framebuffer-test.html:
* fast/canvas/webgl/functions-returning-strings.html:
* fast/canvas/webgl/get-active-test.html:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test.html:
* fast/canvas/webgl/gl-bind-attrib-location-test.html:
* fast/canvas/webgl/gl-bind-attrib-mapped-names.html:
* fast/canvas/webgl/gl-enable-enum-test.html:
* fast/canvas/webgl/gl-enum-tests.html:
* fast/canvas/webgl/gl-get-calls.html:
* fast/canvas/webgl/gl-getshadersource.html:
* fast/canvas/webgl/gl-getstring.html:
* fast/canvas/webgl/gl-object-get-calls.html:
* fast/canvas/webgl/gl-pixelstorei.html:
* fast/canvas/webgl/gl-teximage.html:
* fast/canvas/webgl/gl-uniform-arrays.html:
* fast/canvas/webgl/gl-uniformmatrix4fv.html:
* fast/canvas/webgl/gl-vertex-attrib-zero-issues.html:
* fast/canvas/webgl/gl-vertex-attrib.html:
* fast/canvas/webgl/gl-vertexattribpointer.html:
* fast/canvas/webgl/glsl-conformance.html:
* fast/canvas/webgl/incorrect-context-object-behaviour.html:
* fast/canvas/webgl/index-validation-copies-indices.html:
* fast/canvas/webgl/index-validation-crash-with-buffer-sub-data.html:
* fast/canvas/webgl/index-validation-verifies-too-many-indices.html:
* fast/canvas/webgl/index-validation-with-resized-buffer.html:
* fast/canvas/webgl/index-validation.html:
* fast/canvas/webgl/instanceof-test.html:
* fast/canvas/webgl/invalid-UTF-16.html:
* fast/canvas/webgl/invalid-passed-params.html:
* fast/canvas/webgl/is-object.html:
* fast/canvas/webgl/null-object-behaviour.html:
* fast/canvas/webgl/null-uniform-location.html:
* fast/canvas/webgl/object-deletion-behaviour.html:
* fast/canvas/webgl/oes-element-index-uint.html:
* fast/canvas/webgl/oes-texture-float-linear-expected.txt:
* fast/canvas/webgl/oes-texture-float-linear.html:
* fast/canvas/webgl/oes-texture-half-float-linear-expected.txt:
* fast/canvas/webgl/oes-texture-half-float-linear.html:
* fast/canvas/webgl/oes-texture-half-float-with-canvas.html:
* fast/canvas/webgl/oes-texture-half-float-with-image.html:
* fast/canvas/webgl/oes-texture-half-float-with-video.html:
* fast/canvas/webgl/oes-texture-half-float.html:
* fast/canvas/webgl/oes-vertex-array-object.html:
* fast/canvas/webgl/point-size.html:
* fast/canvas/webgl/premultiplyalpha-test-expected.txt:
* fast/canvas/webgl/premultiplyalpha-test.html:
* fast/canvas/webgl/program-test.html:
* fast/canvas/webgl/read-pixels-pack-alignment.html:
* fast/canvas/webgl/read-pixels-test.html:
* fast/canvas/webgl/renderbuffer-initialization.html:
* fast/canvas/webgl/renderer-and-vendor-strings.html:
* fast/canvas/webgl/resources/tex-image-and-sub-image-2d-with-video.js:
* fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js:
* fast/canvas/webgl/shader-deleted-by-accessor.html:
* fast/canvas/webgl/shader-precision-format.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-array-buffer-view.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-potentially-subsampled-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-svg-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video.html:
* fast/canvas/webgl/tex-image-and-uniform-binding-bugs.html:
* fast/canvas/webgl/tex-image-webgl.html:
* fast/canvas/webgl/tex-image-with-format-and-type.html:
* fast/canvas/webgl/tex-image-with-greyscale-image.html:
* fast/canvas/webgl/tex-input-validation.html:
* fast/canvas/webgl/tex-sub-image-2d-bad-args.html:
* fast/canvas/webgl/tex-sub-image-2d.html:
* fast/canvas/webgl/tex-sub-image-cube-maps.html:
* fast/canvas/webgl/texImageTest.html:
* fast/canvas/webgl/texture-active-bind.html:
* fast/canvas/webgl/texture-bindings-uneffected-on-resize-expected.txt:
* fast/canvas/webgl/texture-bindings-uneffected-on-resize.html:
* fast/canvas/webgl/texture-color-profile.html:
* fast/canvas/webgl/texture-complete.html:
* fast/canvas/webgl/texture-npot.html:
* fast/canvas/webgl/texture-transparent-pixels-initialized.html:
* fast/canvas/webgl/triangle.html:
* fast/canvas/webgl/type-conversion-test.html:
* fast/canvas/webgl/typed-arrays-in-workers.html:
* fast/canvas/webgl/uniform-array-length-overflow.html:
* fast/canvas/webgl/uniform-location-length-limits.html:
* fast/canvas/webgl/uniform-location.html:
* fast/canvas/webgl/uniform-samplers-test.html:
* fast/canvas/webgl/uninitialized-test.html:
* fast/canvas/webgl/viewport-unchanged-upon-resize.html:
* fast/canvas/webgl/webgl-array-invalid-ranges.html:
* fast/canvas/webgl/webgl-compressed-texture-size-limit.html:
* fast/canvas/webgl/webgl-depth-texture-expected.txt:
* fast/canvas/webgl/webgl-depth-texture.html:
* fast/canvas/webgl/webgl-draw-buffers.html:
* fast/canvas/webgl/webgl-exceptions.html:
* fast/canvas/webgl/webgl-specific.html:
* fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt:
* fast/canvas/webgl/webgl-texture-binding-preserved.html:
* fast/canvas/webgl/webgl-unprefixed-context-id.html:
* fast/canvas/webgl/webgl-viewport-parameters-preserved-expected.txt:
* fast/canvas/webgl/webgl-viewport-parameters-preserved.html:
Canonical link: https://commits.webkit.org/157930@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-27 23:22:02 +00:00
// Some tests set jsTestIsAsync in load event handler. Adding the listener late
// makes handleTestFinished() run after the test handles load events.
window . addEventListener ( "load" , handleTestFinished , false ) ;
} , false ) ;
2014-02-12 18:17:47 +00:00
insertStyleSheet ( ) ;
}
if ( ! self . isOnErrorTest ) {
self . onerror = function ( message )
{
if ( self . expectingError ) {
self . expectedErrorMessage = message ;
self . expectingError = false ;
return ;
}
self . unexpectedErrorMessage = message ;
if ( self . jsTestIsAsync ) {
self . testFailed ( "Unexpected error: " + message ) ;
finishJSTest ( ) ;
}
} ;
}
} ) ( ) ;
function isWorker ( )
{
// It's conceivable that someone would stub out 'document' in a worker so
// also check for childNodes, an arbitrary DOM-related object that is
// meaningless in a WorkerContext.
return ( typeof document === 'undefined' || typeof document . childNodes === 'undefined' ) && ! ! self . importScripts ;
}
function descriptionQuiet ( msg ) { description ( msg , true ) ; }
function escapeHTML ( text )
{
return text . replace ( /&/g , "&" ) . replace ( /</g , "<" ) . replace ( /\0/g , "\\0" ) ;
}
function testPassed ( msg )
{
debug ( '<span><span class="pass">PASS</span> ' + escapeHTML ( msg ) + '</span>' ) ;
}
function testFailed ( msg )
{
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
didFailSomeTests = true ;
2014-02-12 18:17:47 +00:00
debug ( '<span><span class="fail">FAIL</span> ' + escapeHTML ( msg ) + '</span>' ) ;
}
function areArraysEqual ( a , b )
{
try {
if ( a . length !== b . length )
return false ;
for ( var i = 0 ; i < a . length ; i ++ )
if ( 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 isNewSVGTearOffType ( v )
{
return [ '[object SVGLength]' , '[object SVGLengthList]' , '[object SVGPoint]' , '[object SVGPointList]' , '[object SVGNumber]' ] . indexOf ( "" + v ) != - 1 ;
}
function isResultCorrect ( actual , expected )
{
if ( expected === 0 )
return actual === expected && ( 1 / actual ) === ( 1 / expected ) ;
if ( actual === expected )
return true ;
// http://crbug.com/308818 : The new implementation of SVGListProperties do not necessary return the same wrapper object, so === operator would not work. We compare for their string representation instead.
if ( isNewSVGTearOffType ( expected ) && typeof ( expected ) == typeof ( actual ) && actual . valueAsString == expected . valueAsString )
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 ) ;
return false ;
}
function stringify ( v )
{
if ( isNewSVGTearOffType ( v ) )
return v . valueAsString ;
if ( v === 0 && 1 / v < 0 )
return "-0" ;
else return "" + v ;
}
function evalAndLog ( _a , _quiet )
{
if ( typeof _a != "string" )
debug ( "WARN: tryAndLog() expects a string argument" ) ;
// Log first in case things go horribly wrong or this causes a sync event.
if ( ! _quiet )
debug ( _a ) ;
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
testFailed ( _a + " threw exception " + e ) ;
}
return _av ;
}
2017-05-02 20:10:12 +00:00
function shouldBe ( _a , _b , _quiet )
2014-02-12 18:17:47 +00:00
{
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 ;
2014-02-12 18:17:47 +00:00
}
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 + ")." ) ;
2014-02-12 18:17:47 +00:00
}
2018-06-01 21:28:40 +00:00
function shouldBeOneOfValues ( _a , _values )
{
if ( ( typeof _a != "function" && typeof _a != "string" ) )
debug ( "WARN: shouldBeOneOfValues() expects the first argument to be a function or a string" ) ;
if ( ! Array . isArray ( _values ) ) {
testFailed ( "The second argument to shouldBeOneOfValues() must be an array of values" ) ;
return ;
}
var _exception ;
var _av ;
try {
_av = ( typeof _a == "function" ? _a ( ) : eval ( _a ) ) ;
} catch ( e ) {
_exception = e ;
}
var stringifiedValues = '' ;
for ( var i = 0 ; i < _values . length ; ++ i ) {
if ( i ) {
if ( i + 1 == _values . length )
stringifiedValues += ', and ' ;
else
stringifiedValues += ','
}
stringifiedValues += "`" + stringify ( _values [ i ] ) + "`" ;
}
if ( _exception )
testFailed ( _a + " should be one of " + stringifiedValues + ". Threw exception " + _exception ) ;
else {
var matchedValue = _values . find ( function ( value ) { return isResultCorrect ( _av , value ) ; } ) ;
2021-05-07 05:00:39 +00:00
if ( matchedValue !== undefined ) {
2018-06-01 21:28:40 +00:00
testPassed ( _a + " is one of " + stringifiedValues ) ;
} else {
testFailed ( _a + " should be one of " + stringifiedValues + ". Was " + stringify ( _av ) + "." ) ;
}
}
}
2014-12-18 17:44:18 +00:00
// Execute condition every 5 milliseconds until it succeeds.
function _waitForCondition ( condition , completionHandler )
2014-02-12 18:17:47 +00:00
{
2014-12-18 17:44:18 +00:00
if ( condition ( ) )
2014-02-12 18:17:47 +00:00
completionHandler ( ) ;
2014-12-18 17:44:18 +00:00
else
setTimeout ( _waitForCondition , 5 , condition , completionHandler ) ;
2014-02-12 18:17:47 +00:00
}
2014-12-18 17:44:18 +00:00
function shouldBecomeEqual ( _a , _b , completionHandler )
2014-02-12 18:17:47 +00:00
{
if ( typeof _a != "string" || typeof _b != "string" )
debug ( "WARN: shouldBecomeEqual() expects string arguments" ) ;
2014-12-23 08:26:49 +00:00
function condition ( ) {
2014-12-18 17:44:18 +00:00
var exception ;
2014-02-12 18:17:47 +00:00
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
2014-12-18 17:44:18 +00:00
exception = e ;
2014-02-12 18:17:47 +00:00
}
2014-12-18 17:44:18 +00:00
var _bv = eval ( _b ) ;
if ( exception )
testFailed ( _a + " should become " + _bv + ". Threw exception " + exception ) ;
2014-02-12 18:17:47 +00:00
if ( isResultCorrect ( _av , _bv ) ) {
testPassed ( _a + " became " + _b ) ;
return true ;
}
return false ;
2014-12-23 08:26:49 +00:00
}
2021-06-09 22:42:51 +00:00
if ( ! completionHandler )
return new Promise ( resolve => setTimeout ( _waitForCondition , 0 , condition , resolve ) ) ;
2014-12-23 08:26:49 +00:00
setTimeout ( _waitForCondition , 0 , condition , completionHandler ) ;
2014-02-12 18:17:47 +00:00
}
2014-12-18 17:44:18 +00:00
function shouldBecomeEqualToString ( value , reference , completionHandler )
2014-02-12 18:17:47 +00:00
{
if ( typeof value !== "string" || typeof reference !== "string" )
debug ( "WARN: shouldBecomeEqualToString() expects string arguments" ) ;
var unevaledString = JSON . stringify ( reference ) ;
2014-12-18 17:44:18 +00:00
shouldBecomeEqual ( value , unevaledString , completionHandler ) ;
2014-02-12 18:17:47 +00:00
}
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 ) ;
}
}
// Variant of shouldBe()--confirms that result of eval(_to_eval) is within
// numeric _tolerance of numeric _target.
function shouldBeCloseTo ( _to _eval , _target , _tolerance , _quiet )
{
if ( typeof _to _eval != "string" ) {
testFailed ( "shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to _eval ) ;
return ;
}
if ( typeof _target != "number" ) {
testFailed ( "shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target ) ;
return ;
}
if ( typeof _tolerance != "number" ) {
testFailed ( "shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance ) ;
return ;
}
var _result ;
try {
_result = eval ( _to _eval ) ;
} catch ( e ) {
testFailed ( _to _eval + " should be within " + _tolerance + " of "
+ _target + ". Threw exception " + e ) ;
return ;
}
if ( typeof ( _result ) != typeof ( _target ) ) {
testFailed ( _to _eval + " should be of type " + typeof _target
+ " but was of type " + typeof _result ) ;
} else if ( Math . abs ( _result - _target ) <= _tolerance ) {
if ( ! _quiet ) {
testPassed ( _to _eval + " is within " + _tolerance + " of " + _target ) ;
}
} else {
testFailed ( _to _eval + " should be within " + _tolerance + " of " + _target
+ ". Was " + _result + "." ) ;
}
}
function shouldNotBe ( _a , _b , _quiet )
{
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 ;
2014-02-12 18:17:47 +00:00
}
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 + "." ) ;
2014-02-12 18:17:47 +00:00
}
2014-12-18 17:44:18 +00:00
function shouldBecomeDifferent ( _a , _b , completionHandler )
2014-02-12 18:17:47 +00:00
{
if ( typeof _a != "string" || typeof _b != "string" )
debug ( "WARN: shouldBecomeDifferent() expects string arguments" ) ;
2014-12-23 08:26:49 +00:00
function condition ( ) {
2014-12-18 17:44:18 +00:00
var exception ;
2014-02-12 18:17:47 +00:00
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
2014-12-18 17:44:18 +00:00
exception = e ;
2014-02-12 18:17:47 +00:00
}
2014-12-18 17:44:18 +00:00
var _bv = eval ( _b ) ;
if ( exception )
testFailed ( _a + " should became not equal to " + _bv + ". Threw exception " + exception ) ;
2014-02-12 18:17:47 +00:00
if ( ! isResultCorrect ( _av , _bv ) ) {
testPassed ( _a + " became different from " + _b ) ;
return true ;
}
return false ;
2014-12-23 08:26:49 +00:00
}
2021-06-09 22:42:51 +00:00
if ( ! completionHandler )
return new Promise ( resolve => setTimeout ( _waitForCondition , 0 , condition , resolve ) ) ;
2014-12-23 08:26:49 +00:00
setTimeout ( _waitForCondition , 0 , condition , completionHandler ) ;
2014-02-12 18:17:47 +00:00
}
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 )
{
if ( typeof a !== "string" || typeof b !== "string" )
debug ( "WARN: shouldBeEqualToString() expects string arguments" ) ;
var unevaledString = JSON . stringify ( b ) ;
shouldBe ( a , unevaledString ) ;
}
2014-12-16 18:42:43 +00:00
function shouldBeEqualToNumber ( a , b )
{
if ( typeof a !== "string" || typeof b !== "number" )
debug ( "WARN: shouldBeEqualToNumber() expects a string and a number arguments" ) ;
var unevaledString = JSON . stringify ( b ) ;
shouldBe ( a , unevaledString ) ;
}
2014-02-12 18:17:47 +00:00
function shouldBeEmptyString ( a ) { shouldBeEqualToString ( a , "" ) ; }
function shouldEvaluateTo ( actual , expected ) {
// A general-purpose comparator. 'actual' should be a string to be
// evaluated, as for shouldBe(). 'expected' may be any type and will be
// used without being eval'ed.
if ( expected == null ) {
// Do this before the object test, since null is of type 'object'.
shouldBeNull ( actual ) ;
} else if ( typeof expected == "undefined" ) {
shouldBeUndefined ( actual ) ;
} else if ( typeof expected == "function" ) {
// All this fuss is to avoid the string-arg warning from shouldBe().
try {
var actualValue = eval ( actual ) ;
} catch ( e ) {
testFailed ( "Evaluating " + actual + ": Threw exception " + e ) ;
return ;
}
shouldBe ( "'" + actualValue . toString ( ) . replace ( /\n/g , "" ) + "'" ,
"'" + expected . toString ( ) . replace ( /\n/g , "" ) + "'" ) ;
} else if ( typeof expected == "object" ) {
shouldBeTrue ( actual + " == '" + expected + "'" ) ;
} else if ( typeof expected == "string" ) {
shouldBe ( actual , expected ) ;
} else if ( typeof expected == "boolean" ) {
shouldBe ( "typeof " + actual , "'boolean'" ) ;
if ( expected )
shouldBeTrue ( actual ) ;
else
shouldBeFalse ( actual ) ;
} else if ( typeof expected == "number" ) {
shouldBe ( actual , stringify ( expected ) ) ;
} else {
debug ( expected + " is unknown type " + typeof expected ) ;
shouldBeTrue ( actual , "'" + expected . toString ( ) + "'" ) ;
}
}
function shouldBeNonZero ( _a )
{
var _exception ;
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
_exception = e ;
}
if ( _exception )
testFailed ( _a + " should be non-zero. Threw exception " + _exception ) ;
else if ( _av != 0 )
testPassed ( _a + " is non-zero." ) ;
else
testFailed ( _a + " should be non-zero. Was " + _av ) ;
}
function shouldBeNonNull ( _a )
{
var _exception ;
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
_exception = e ;
}
if ( _exception )
testFailed ( _a + " should be non-null. Threw exception " + _exception ) ;
else if ( _av != null )
testPassed ( _a + " is non-null." ) ;
else
testFailed ( _a + " should be non-null. Was " + _av ) ;
}
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 ) ;
}
function shouldBeGreaterThanOrEqual ( _a , _b ) {
if ( typeof _a != "string" || typeof _b != "string" )
debug ( "WARN: shouldBeGreaterThanOrEqual expects string arguments" ) ;
var _exception ;
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
_exception = e ;
}
var _bv = eval ( _b ) ;
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
testPassed ( _a + " is >= " + _b ) ;
}
2020-07-15 20:28:06 +00:00
function shouldBeLessThanOrEqual ( _a , _b ) {
if ( typeof _a != "string" || typeof _b != "string" )
debug ( "WARN: shouldBeLessThanOrEqual expects string arguments" ) ;
var _exception ;
var _av ;
try {
_av = eval ( _a ) ;
} catch ( e ) {
_exception = e ;
}
var _bv = eval ( _b ) ;
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
testPassed ( _a + " is <= " + _b ) ;
}
fast/canvas/webgl/angle-instanced-arrays.html is very flaky
https://bugs.webkit.org/show_bug.cgi?id=139958
Reviewed by Darin Adler.
WebGL test harness added js-test-post.js in a flaky manner, and to make things worse,
this test also had its own include of js-test-post.js.
Looking at the tests, I noticed that the way test harnesses were used was a big mess,
so I went over the whole directory, making these changes:
1. Use js-test.js instead of js-test-pre.js, because it's simpler and better macthes
the Khronos test model.
2. Removed js-test-post.js everywhere (some tests included it in particularly crazy ways).
3. Removed successfullyParsed = true, as js-test.js doesn't need that.
4. Updated DOCTYPE, while editing these tests anyway.
5. Tests now have correct order of lines in the output (no longer saying TEST COMPLETE
before PASS), so updated results.
6. In js-test tests, we shouldn't use waitUntilDone/notifyDone explicitly, so
updated these with jsTestIsAsync.
7. Updated async tests that used initNonKhronosFramework(false) plus some way to
become async to simply say initNonKhronosFramework(true).
8. Removed isSuccessfullyParsed() calls that several tests were using as an ugly
workaround for issues caused by misusing the harness. This is never expected to be
called directly.
* fast/canvas/webgl/angle-instanced-arrays-out-of-bounds.html:
Removed an unneeded js-test-style.css include.
* fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html:
Swapped lines to not have glErrorShouldBe after finishTest.
* fast/canvas/webgl/resources/webgl-test.js:
(initNonKhronosFramework): webgl-test.js relies on js-test anyway, so there is
no need to duplicate the work.
(nonKhronosFrameworkNotifyDone): Use the proper js-test mechanism.
(finishTest): Ditto.
(finishTest.epilogue.document.createElement.epilogue.onload): Deleted.
* resources/js-test.js:
(expectTrue): Added this function that we only has in js-test-pre.js.
(): Perform work after test's load event handler, not immediately on DOMContentLoaded.
This has two benefits:
1. Tests that enable jsTestIsAsync in onload do work. This is expected, because
tests that call waitUntilDone from onload also do work.
2. Non-async tests that perform work in onload have the correct order of lines in output.
* fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt:
* fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt:
* fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt:
* fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
* fast/hidpi/image-srcset-src-selection-1x-both-expected.txt:
* svg/custom/html_document_set_title-expected.txt:
Updated results for js-test.js improvements.
* fast/canvas/webgl/WebGLContextEvent.html:
* fast/canvas/webgl/angle-instanced-arrays.html:
* fast/canvas/webgl/array-bounds-clamping.html:
* fast/canvas/webgl/array-buffer-crash.html:
* fast/canvas/webgl/array-buffer-view-crash-when-reassigned.html:
* fast/canvas/webgl/array-buffer-view-crash.html:
* fast/canvas/webgl/array-constructor.html:
* fast/canvas/webgl/array-get-and-set-method-removal.html:
* fast/canvas/webgl/array-get-out-of-bounds.html:
* fast/canvas/webgl/array-message-passing.html:
* fast/canvas/webgl/array-override-set.html:
* fast/canvas/webgl/array-set-invalid-arguments.html:
* fast/canvas/webgl/array-set-out-of-bounds.html:
* fast/canvas/webgl/array-set-with-offset.html:
* fast/canvas/webgl/array-setters.html:
* fast/canvas/webgl/array-unit-tests.html:
* fast/canvas/webgl/arraybuffer-transfer-of-control.html:
* fast/canvas/webgl/attrib-location-length-limits.html:
* fast/canvas/webgl/bad-arguments-test.html:
* fast/canvas/webgl/buffer-bind-test.html:
* fast/canvas/webgl/buffer-data-array-buffer.html:
* fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt:
* fast/canvas/webgl/canvas-2d-webgl-texture.html:
* fast/canvas/webgl/canvas-resize-crash.html:
* fast/canvas/webgl/canvas-supports-context.html:
* fast/canvas/webgl/canvas-test.html:
* fast/canvas/webgl/canvas-zero-size.html:
* fast/canvas/webgl/compressed-tex-image.html:
* fast/canvas/webgl/constants.html:
* fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html:
* fast/canvas/webgl/context-creation-and-destruction.html:
* fast/canvas/webgl/context-lost-restored.html:
* fast/canvas/webgl/context-lost.html:
* fast/canvas/webgl/context-release-upon-reload.html:
* fast/canvas/webgl/copy-tex-image-and-sub-image-2d.html:
* fast/canvas/webgl/data-view-crash.html:
* fast/canvas/webgl/data-view-test.html:
* fast/canvas/webgl/draw-arrays-out-of-bounds.html:
* fast/canvas/webgl/draw-elements-out-of-bounds.html:
* fast/canvas/webgl/drawingbuffer-test.html:
* fast/canvas/webgl/error-reporting.html:
* fast/canvas/webgl/framebuffer-object-attachment.html:
* fast/canvas/webgl/framebuffer-test.html:
* fast/canvas/webgl/functions-returning-strings.html:
* fast/canvas/webgl/get-active-test.html:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test.html:
* fast/canvas/webgl/gl-bind-attrib-location-test.html:
* fast/canvas/webgl/gl-bind-attrib-mapped-names.html:
* fast/canvas/webgl/gl-enable-enum-test.html:
* fast/canvas/webgl/gl-enum-tests.html:
* fast/canvas/webgl/gl-get-calls.html:
* fast/canvas/webgl/gl-getshadersource.html:
* fast/canvas/webgl/gl-getstring.html:
* fast/canvas/webgl/gl-object-get-calls.html:
* fast/canvas/webgl/gl-pixelstorei.html:
* fast/canvas/webgl/gl-teximage.html:
* fast/canvas/webgl/gl-uniform-arrays.html:
* fast/canvas/webgl/gl-uniformmatrix4fv.html:
* fast/canvas/webgl/gl-vertex-attrib-zero-issues.html:
* fast/canvas/webgl/gl-vertex-attrib.html:
* fast/canvas/webgl/gl-vertexattribpointer.html:
* fast/canvas/webgl/glsl-conformance.html:
* fast/canvas/webgl/incorrect-context-object-behaviour.html:
* fast/canvas/webgl/index-validation-copies-indices.html:
* fast/canvas/webgl/index-validation-crash-with-buffer-sub-data.html:
* fast/canvas/webgl/index-validation-verifies-too-many-indices.html:
* fast/canvas/webgl/index-validation-with-resized-buffer.html:
* fast/canvas/webgl/index-validation.html:
* fast/canvas/webgl/instanceof-test.html:
* fast/canvas/webgl/invalid-UTF-16.html:
* fast/canvas/webgl/invalid-passed-params.html:
* fast/canvas/webgl/is-object.html:
* fast/canvas/webgl/null-object-behaviour.html:
* fast/canvas/webgl/null-uniform-location.html:
* fast/canvas/webgl/object-deletion-behaviour.html:
* fast/canvas/webgl/oes-element-index-uint.html:
* fast/canvas/webgl/oes-texture-float-linear-expected.txt:
* fast/canvas/webgl/oes-texture-float-linear.html:
* fast/canvas/webgl/oes-texture-half-float-linear-expected.txt:
* fast/canvas/webgl/oes-texture-half-float-linear.html:
* fast/canvas/webgl/oes-texture-half-float-with-canvas.html:
* fast/canvas/webgl/oes-texture-half-float-with-image.html:
* fast/canvas/webgl/oes-texture-half-float-with-video.html:
* fast/canvas/webgl/oes-texture-half-float.html:
* fast/canvas/webgl/oes-vertex-array-object.html:
* fast/canvas/webgl/point-size.html:
* fast/canvas/webgl/premultiplyalpha-test-expected.txt:
* fast/canvas/webgl/premultiplyalpha-test.html:
* fast/canvas/webgl/program-test.html:
* fast/canvas/webgl/read-pixels-pack-alignment.html:
* fast/canvas/webgl/read-pixels-test.html:
* fast/canvas/webgl/renderbuffer-initialization.html:
* fast/canvas/webgl/renderer-and-vendor-strings.html:
* fast/canvas/webgl/resources/tex-image-and-sub-image-2d-with-video.js:
* fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js:
* fast/canvas/webgl/shader-deleted-by-accessor.html:
* fast/canvas/webgl/shader-precision-format.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-array-buffer-view.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-potentially-subsampled-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-svg-image.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgb565.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgba4444.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video-rgba5551.html:
* fast/canvas/webgl/tex-image-and-sub-image-2d-with-video.html:
* fast/canvas/webgl/tex-image-and-uniform-binding-bugs.html:
* fast/canvas/webgl/tex-image-webgl.html:
* fast/canvas/webgl/tex-image-with-format-and-type.html:
* fast/canvas/webgl/tex-image-with-greyscale-image.html:
* fast/canvas/webgl/tex-input-validation.html:
* fast/canvas/webgl/tex-sub-image-2d-bad-args.html:
* fast/canvas/webgl/tex-sub-image-2d.html:
* fast/canvas/webgl/tex-sub-image-cube-maps.html:
* fast/canvas/webgl/texImageTest.html:
* fast/canvas/webgl/texture-active-bind.html:
* fast/canvas/webgl/texture-bindings-uneffected-on-resize-expected.txt:
* fast/canvas/webgl/texture-bindings-uneffected-on-resize.html:
* fast/canvas/webgl/texture-color-profile.html:
* fast/canvas/webgl/texture-complete.html:
* fast/canvas/webgl/texture-npot.html:
* fast/canvas/webgl/texture-transparent-pixels-initialized.html:
* fast/canvas/webgl/triangle.html:
* fast/canvas/webgl/type-conversion-test.html:
* fast/canvas/webgl/typed-arrays-in-workers.html:
* fast/canvas/webgl/uniform-array-length-overflow.html:
* fast/canvas/webgl/uniform-location-length-limits.html:
* fast/canvas/webgl/uniform-location.html:
* fast/canvas/webgl/uniform-samplers-test.html:
* fast/canvas/webgl/uninitialized-test.html:
* fast/canvas/webgl/viewport-unchanged-upon-resize.html:
* fast/canvas/webgl/webgl-array-invalid-ranges.html:
* fast/canvas/webgl/webgl-compressed-texture-size-limit.html:
* fast/canvas/webgl/webgl-depth-texture-expected.txt:
* fast/canvas/webgl/webgl-depth-texture.html:
* fast/canvas/webgl/webgl-draw-buffers.html:
* fast/canvas/webgl/webgl-exceptions.html:
* fast/canvas/webgl/webgl-specific.html:
* fast/canvas/webgl/webgl-texture-binding-preserved-expected.txt:
* fast/canvas/webgl/webgl-texture-binding-preserved.html:
* fast/canvas/webgl/webgl-unprefixed-context-id.html:
* fast/canvas/webgl/webgl-viewport-parameters-preserved-expected.txt:
* fast/canvas/webgl/webgl-viewport-parameters-preserved.html:
Canonical link: https://commits.webkit.org/157930@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-27 23:22:02 +00:00
function expectTrue ( v , msg ) {
if ( v ) {
testPassed ( msg ) ;
} else {
testFailed ( msg ) ;
}
}
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
function shouldNotThrow ( _a , _message ) {
2014-02-12 18:17:47 +00:00
try {
2017-05-02 20:10:12 +00:00
typeof _a == "function" ? _a ( ) : eval ( _a ) ;
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
testPassed ( ( _message ? _message : _a ) + " did not throw exception." ) ;
2014-02-12 18:17:47 +00:00
} catch ( e ) {
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
testFailed ( ( _message ? _message : _a ) + " should not throw exception. Threw exception " + e + "." ) ;
2014-02-12 18:17:47 +00:00
}
}
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
function shouldThrow ( _a , _e , _message )
2014-02-12 18:17:47 +00:00
{
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
var _exception ;
var _av ;
try {
_av = typeof _a == "function" ? _a ( ) : eval ( _a ) ;
} catch ( e ) {
_exception = e ;
}
2014-02-12 18:17:47 +00:00
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
var _ev ;
if ( _e )
_ev = eval ( _e ) ;
2014-02-12 18:17:47 +00:00
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +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." ) ;
2014-02-12 18:17:47 +00:00
else
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
testFailed ( ( _message ? _message : _a ) + " should throw " + ( typeof _e == "undefined" ? "an exception" : _ev ) + ". Was " + _av + "." ) ;
2014-02-12 18:17:47 +00:00
}
function shouldBeNow ( a , delta )
{
// Right now, V8 and Chromium / Blink use two different clock
// implementations. On Windows, the implementations are non-trivial and can
// be slightly out of sync. The delta is intended to compensate for that.
//
// FIXME: reconsider this when the V8 and Blink clocks get unified, see http://crbug.com/324110
if ( delta === undefined )
delta = 1000 ;
for ( var i = 0 ; i < 1000 ; ++ i ) {
var startDate = Date . now ( ) ;
var av = eval ( a ) ;
var date = av . valueOf ( ) ;
var endDate = Date . now ( ) ;
// On some occasions such as NTP updates, the current time can go
// backwards. This should only happen rarely, so we can get away with
// retrying the test a few times if we detect the time going backwards.
if ( startDate > endDate )
continue ;
if ( typeof date !== "number" ) {
testFailed ( a + " is not a number or a Date. Got " + av ) ;
return ;
}
if ( date < startDate - delta ) {
testFailed ( a + " is not the curent time. Got " + av + " which is " + ( startDate - date ) / 1000 + " seconds in the past." ) ;
return ;
}
if ( date > endDate + delta ) {
testFailed ( a + " is not the current time. Got " + av + " which is " + ( date - endDate ) / 1000 + " seconds in the future." ) ;
return ;
}
testPassed ( a + " is equivalent to Date.now()." ) ;
return ;
}
testFailed ( a + " cannot be tested against the current time. The clock is going backwards too often." ) ;
}
function expectError ( )
{
if ( expectingError ) {
testFailed ( "shouldHaveError() called twice before an error occurred!" ) ;
}
expectingError = true ;
}
2017-05-22 20:49:12 +00:00
function shouldReject ( _a , _message )
2019-11-11 22:13:55 +00:00
{
return shouldRejectWithErrorName ( _a , undefined , _message ) ;
}
function shouldRejectWithErrorName ( _a , _name , _message )
2017-05-22 20:49:12 +00:00
{
var _exception ;
var _av ;
try {
_av = typeof _a == "function" ? _a ( ) : eval ( _a ) ;
} catch ( e ) {
testFailed ( ( _message ? _message : _a ) + " should not throw exception. Threw exception " + e + "." ) ;
return Promise . resolve ( ) ;
}
return _av . then ( function ( result ) {
testFailed ( ( _message ? _message : _a ) + " should reject promise. Resolved with " + result + "." ) ;
} , function ( error ) {
2020-04-23 17:26:14 +00:00
if ( _name === undefined ) {
testPassed ( ( _message ? _message : _a ) + " rejected promise." ) ;
} else if ( error [ 'name' ] === _name ) {
2019-11-11 22:13:55 +00:00
// FIXME: Remove the extra space and '.' (DOMException descriptions already end with periods) then rebase tests.
testPassed ( ( _message ? _message : _a ) + " rejected promise with " + error + "." ) ;
} else
testFailed ( ( _message ? _message : _a ) + " should reject promise with " + _name + ". Rejected with " + error [ 'name' ] + " instead." ) ;
2017-05-22 20:49:12 +00:00
} ) ;
}
function shouldThrowErrorName ( _a , _name )
{
var _exception ;
try {
typeof _a == "function" ? _a ( ) : eval ( _a ) ;
} catch ( e ) {
_exception = e ;
}
if ( _exception ) {
if ( _exception . name == _name )
testPassed ( _a + " threw exception " + _exception + "." ) ;
else
testFailed ( _a + " should throw a " + _name + ". Threw a " + _exception . name + "." ) ;
} else
testFailed ( _a + " should throw a " + _name + ". Did not throw." ) ;
}
2014-02-12 18:17:47 +00:00
function shouldHaveHadError ( message )
{
if ( expectingError ) {
testFailed ( "No error thrown between expectError() and shouldHaveHadError()" ) ;
return ;
}
if ( expectedErrorMessage ) {
if ( ! message )
testPassed ( "Got expected error" ) ;
else if ( expectedErrorMessage . indexOf ( message ) !== - 1 )
testPassed ( "Got expected error: '" + message + "'" ) ;
else
testFailed ( "Unexpected error '" + message + "'" ) ;
expectedErrorMessage = undefined ;
return ;
}
testFailed ( "expectError() not called before shouldHaveHadError()" ) ;
}
function gc ( ) {
if ( typeof GCController !== "undefined" )
GCController . collect ( ) ;
else {
var gcRec = function ( n ) {
if ( n < 1 )
return { } ;
var temp = { i : "ab" + i + ( i / 100000 ) } ;
temp += "foo" ;
gcRec ( n - 1 ) ;
} ;
for ( var i = 0 ; i < 1000 ; i ++ )
gcRec ( 10 ) ;
}
}
function minorGC ( ) {
if ( typeof GCController !== "undefined" )
GCController . minorCollect ( ) ;
else
testFailed ( "Minor GC is available only when you enable the --expose-gc option in V8." ) ;
}
function isSuccessfullyParsed ( )
{
// FIXME: Remove this and only report unexpected syntax errors.
successfullyParsed = ! unexpectedErrorMessage ;
shouldBeTrue ( "successfullyParsed" ) ;
Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message
<https://webkit.org/b/159232>
Reviewed by Brent Fulgham.
Based on a Blink change (patch by <hongchan@chromium.org>):
<https://src.chromium.org/viewvc/blink?view=revision&revision=192204>
Currently, shouldNotThrow() and shouldThrow() take the following
arguments:
shouldNotThrow(evalString)
shouldThrow(evalString, expectedExceptionString)
The challenges with this design are:
1) The 'evalString' must capture every variable that it
needs, which means the code can be long, and concatenated
into a single line. It would be really nice to be able
to use an (anonymous) function to capture variables
instead.
2) The 'evalString' is literally printed out in the test
results, which isn't always the most descriptive. A
descriptive message would make it clearer what failed.
3) When changing a shouldThrow() into a shouldNotThrow()
or copying/pasting code, it's possible to forget to
remove 'expectedExceptionString' from the function call.
This patch changes the methods to take the following arguments:
shouldNotThrow(evalString|function [, message])
shouldThrow(evalString|function, expectedExceptionString [, message])
If 'function' is passed in, then it is invoked instead of
evaluated, and 'message' replaces the literal code in the
pass/fail output.
This patch also adds the global 'didFailSomeTests' variable to
js-test.js, which already exists in js-test-pre.js. This was
added to js-test-pre.js in r153203 by Oliver Hunt to
LayoutTests/fast/js/resources/js-test-pre.js.
* fast/canvas/webgl/canvas-supports-context-expected.txt:
* fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt:
* fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
* fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt:
* storage/indexeddb/cursor-basics-expected.txt:
* storage/indexeddb/cursor-basics-private-expected.txt:
- Update expected results to include "Some tests fail." since
some subtests actually do fail during these tests.
* fast/css/parsing-css-lang.html:
* fast/css/parsing-css-matches-1.html:
* fast/css/parsing-css-matches-2.html:
* fast/css/parsing-css-matches-3.html:
* fast/css/parsing-css-matches-4.html:
* fast/css/parsing-css-not-1.html:
* fast/css/parsing-css-not-2.html:
* fast/css/parsing-css-not-3.html:
* fast/css/parsing-css-not-4.html:
* fast/css/parsing-css-nth-child-of-1.html:
* fast/css/parsing-css-nth-child-of-2.html:
* fast/css/parsing-css-nth-last-child-of-1.html:
* fast/css/parsing-css-nth-last-child-of-2.html:
* js/script-tests/arrowfunction-supercall.js:
- Remove expectedExceptionString from shouldNotThrow() calls
after they were changed from shouldThrow() calls.
* resources/js-test-pre.js:
(shouldNotThrow): Change to invoke first argument if it is a
function, else use eval() as before. Use second argurment in
place of first argument (if set) when printing results. NOTE:
Care was taken not to add any lines of code to prevent changes
to test results.
(shouldThrow): Ditto. Reformat code.
* resources/js-test.js: Declare 'didFailSomeTests'.
(testFailed): Set 'didFailSomeTests' to true when a test fails.
(shouldNotThrow): Same changes as js-test-pre.js.
(shouldThrow): Ditto.
(isSuccessfullyParsed): Output a message if 'didFailSomeTests'
is true.
Canonical link: https://commits.webkit.org/177356@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-29 04:17:36 +00:00
if ( didFailSomeTests )
debug ( "Some tests failed." ) ;
2014-02-12 18:17:47 +00:00
debug ( '<br /><span class="pass">TEST COMPLETE</span>' ) ;
}
// It's possible for an async test to call finishJSTest() before js-test-post.js
// has been parsed.
function finishJSTest ( )
{
wasFinishJSTestCalled = true ;
if ( ! self . wasPostTestScriptParsed )
return ;
isSuccessfullyParsed ( ) ;
2017-10-25 01:35:45 +00:00
moveForeignObjectToTopIfNeeded ( ) ;
2014-02-12 18:17:47 +00:00
if ( self . jsTestIsAsync && self . testRunner )
testRunner . notifyDone ( ) ;
}
2016-11-01 23:51:54 +00:00
function areObjectsEqual ( a , b ) {
for ( var property in a ) {
if ( ! b . hasOwnProperty ( property ) )
return false ;
switch ( typeof ( a [ property ] ) ) {
case 'function' :
if ( typeof b [ property ] == 'undefined' || a [ property ] . toString ( ) != b [ property ] . toString ( ) )
return false ;
break ;
case 'object' :
if ( ! areObjectsEqual ( a , b ) )
return false ;
break ;
default :
if ( a [ property ] != b [ property ] )
return false ;
}
}
for ( var property in b ) {
if ( ! a . hasOwnProperty ( property ) )
return false ;
}
return true ;
} ;
2015-01-13 00:40:49 +00:00
function startWorker ( testScriptURL )
2014-02-12 18:17:47 +00:00
{
self . jsTestIsAsync = true ;
debug ( 'Starting worker: ' + testScriptURL ) ;
2015-01-13 00:40:49 +00:00
var worker = new Worker ( testScriptURL ) ;
2014-02-12 18:17:47 +00:00
worker . onmessage = function ( event )
{
var workerPrefix = "[Worker] " ;
if ( event . data . length < 5 || event . data . charAt ( 4 ) != ':' ) {
debug ( workerPrefix + event . data ) ;
return ;
}
var code = event . data . substring ( 0 , 4 ) ;
var payload = workerPrefix + event . data . substring ( 5 ) ;
if ( code == "PASS" )
testPassed ( payload ) ;
else if ( code == "FAIL" )
testFailed ( payload ) ;
else if ( code == "DESC" )
description ( payload ) ;
else if ( code == "DONE" )
finishJSTest ( ) ;
else
debug ( workerPrefix + event . data ) ;
} ;
worker . onerror = function ( event )
{
debug ( 'Got error from worker: ' + event . message ) ;
finishJSTest ( ) ;
} ;
return worker ;
}
if ( isWorker ( ) ) {
var workerPort = self ;
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 ) ;
} ;
}
2019-09-27 05:13:10 +00:00
function downgradeReferrerCallback ( policy , host ) {
let scriptElement = document . createElement ( "script" ) ;
2021-04-02 18:35:21 +00:00
scriptElement . src = "http://" . concat ( host , ":8000/referrer-policy/resources/script.py" ) ;
2019-09-27 05:13:10 +00:00
scriptElement . referrerPolicy = policy ;
document . body . appendChild ( scriptElement ) ;
}