2010-07-13 Andreas Kling <andreas.kling@nokia.com>

        Reviewed by Darin Adler.

        Canvas: drawImage() with wrong 'image' argument type should always throw TypeError
        https://bugs.webkit.org/show_bug.cgi?id=42160

        Updated 2d.drawImage.wrongtype.html from http://dvcs.w3.org/hg/html/
        and unskipped it.

        * canvas/philip/tests/2d.drawImage.wrongtype-expected.txt:
        * canvas/philip/tests/2d.drawImage.wrongtype.html:
        * platform/mac/Skipped:
        * platform/qt/Skipped:
2010-07-13  Andreas Kling  <andreas.kling@nokia.com>

        Reviewed by Darin Adler.

        Canvas: drawImage() with wrong 'image' argument type should always throw TypeError
        https://bugs.webkit.org/show_bug.cgi?id=42160

        Test: canvas/philip/tests/2d.drawImage.wrongtype.html

        * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
        (WebCore::JSCanvasRenderingContext2D::drawImage): Throw TypeError instead of
        TYPE_MISMATCH_ERR if 'image' argument is not an image, canvas or video element.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63252 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0bee29b4
2010-07-13 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Darin Adler.
Canvas: drawImage() with wrong 'image' argument type should always throw TypeError
https://bugs.webkit.org/show_bug.cgi?id=42160
Updated 2d.drawImage.wrongtype.html from http://dvcs.w3.org/hg/html/
and unskipped it.
* canvas/philip/tests/2d.drawImage.wrongtype-expected.txt:
* canvas/philip/tests/2d.drawImage.wrongtype.html:
* platform/mac/Skipped:
* platform/qt/Skipped:
2010-07-13 Kenneth Russell <kbr@google.com>
Reviewed by Darin Fisher.
< [index] >
2d.drawImage.wrongtype
References: 2d.drawImage.type
Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError
Spec references: 2d.drawImage.type
Defined in "Language Bindings for DOM Specifications" (draft)
Actual output:
Passed
<!DOCTYPE html>
<title>Canvas test: 2d.drawImage.wrongtype</title>
<meta name="author" content="Philip Taylor">
<script src="../tests.js"></script>
<link rel="stylesheet" href="../tests.css">
<link rel="prev" href="2d.drawImage.null.html" title="2d.drawImage.null">
<link rel="next" href="2d.drawImage.floatsource.html" title="2d.drawImage.floatsource">
<body class="show_output">
<p>
<a href="2d.drawImage.null.html" accesskey="p" title="[p] 2d.drawImage.null">&lt;</a>
<a href="index.html">[index]</a>
<a href="2d.drawImage.floatsource.html" accesskey="n" title="[n] 2d.drawImage.floatsource">&gt;</a>
<h1><a href="index.2d.html">2d</a>.<a href="index.2d.drawImage.html">drawImage</a>.wrongtype</h1>
<p class="desc"></p>
<div class="refs">References:
<ul>
<li><a href="spec.html#testrefs.2d.drawImage.type">2d.drawImage.type</a>
<p class="desc">Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError</p>
<div class="refs">Spec references:
<ul>
<li><a href="../annotated-spec/canvas.html#testrefs.2d.drawImage.type">2d.drawImage.type</a>
</ul>
</div>
<p class="notes">Defined in "Language Bindings for DOM Specifications" (draft)
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
......@@ -27,16 +23,16 @@ _addTest(function(canvas, ctx) {
try { var _thrown = false;
ctx.drawImage(undefined, 0, 0);
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(undefined, 0, 0)"); }
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.drawImage(undefined, 0, 0)"); }
try { var _thrown = false;
ctx.drawImage(0, 0, 0);
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(0, 0, 0)"); }
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.drawImage(0, 0, 0)"); }
try { var _thrown = false;
ctx.drawImage("", 0, 0);
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(\"\", 0, 0)"); }
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.drawImage(\"\", 0, 0)"); }
try { var _thrown = false;
ctx.drawImage(document.createElement('p'), 0, 0);
} catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) _fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(document.createElement('p'), 0, 0)"); }
} catch (e) { if (!(e instanceof TypeError)) _fail("Failed assertion: expected exception of type TypeError, got: "+e); _thrown = true; } finally { _assert(_thrown, "should throw exception of type TypeError: ctx.drawImage(document.createElement('p'), 0, 0)"); }
});
......
......@@ -200,7 +200,6 @@ canvas/philip/tests/2d.composite.uncovered.pattern.source-out.html
canvas/philip/tests/2d.drawImage.broken.html
canvas/philip/tests/2d.drawImage.incomplete.html
canvas/philip/tests/2d.drawImage.null.html
canvas/philip/tests/2d.drawImage.wrongtype.html
canvas/philip/tests/2d.fillStyle.parse.current.basic.html
canvas/philip/tests/2d.fillStyle.parse.current.changed.html
canvas/philip/tests/2d.fillStyle.parse.current.removed.html
......
......@@ -5258,7 +5258,6 @@ canvas/philip/tests/2d.composite.uncovered.pattern.source-out.html
canvas/philip/tests/2d.drawImage.broken.html
canvas/philip/tests/2d.drawImage.incomplete.html
canvas/philip/tests/2d.drawImage.null.html
canvas/philip/tests/2d.drawImage.wrongtype.html
canvas/philip/tests/2d.fillStyle.parse.current.basic.html
canvas/philip/tests/2d.fillStyle.parse.current.changed.html
canvas/philip/tests/2d.fillStyle.parse.current.removed.html
......
2010-07-13 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Darin Adler.
Canvas: drawImage() with wrong 'image' argument type should always throw TypeError
https://bugs.webkit.org/show_bug.cgi?id=42160
Test: canvas/philip/tests/2d.drawImage.wrongtype.html
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::JSCanvasRenderingContext2D::drawImage): Throw TypeError instead of
TYPE_MISMATCH_ERR if 'image' argument is not an image, canvas or video element.
2010-07-13 Aaron Boodman <aa@chromium.org>
Reviewed by Timothy Hatcher.
......@@ -260,9 +260,8 @@ JSValue JSCanvasRenderingContext2D::drawImage(ExecState* exec)
return throwSyntaxError(exec);
}
#endif
} else {
setDOMException(exec, TYPE_MISMATCH_ERR);
}
} else
return throwTypeError(exec);
return jsUndefined();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment