Bug 616401 - nsHTMLCanvasElement::GetContext ignores JS exceptions; r=bz

This commit is contained in:
Ms2ger 2012-05-18 10:29:39 +02:00
parent 96284cb920
commit 455a830eeb
3 changed files with 15 additions and 7 deletions

View File

@ -0,0 +1,8 @@
<!doctype html>
<script>
var c = document.createElement("canvas");
c.getContext("experimental-webgl", {
get a() { throw 7; },
get b() { throw 8; }
});
</script>

View File

@ -27,6 +27,7 @@ load 602117.html
load 613027.html
load 614279.html
load 614988-1.html
load 616401.html
load 620078-1.html
load 620078-2.html
load 680922-1.xul

View File

@ -526,20 +526,19 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
// this to know how to create nsISupportsStrings etc.
nsCOMPtr<nsIWritablePropertyBag2> contextProps;
if (aContextOptions.isObject())
{
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (aContextOptions.isObject()) {
JSContext* cx = nsContentUtils::GetCurrentJSContext();
contextProps = do_CreateInstance("@mozilla.org/hash-property-bag;1");
JSObject *opts = &aContextOptions.toObject();
JS::AutoIdArray props(cx, JS_Enumerate(cx, opts));
JSObject& opts = aContextOptions.toObject();
JS::AutoIdArray props(cx, JS_Enumerate(cx, &opts));
for (size_t i = 0; !!props && i < props.length(); ++i) {
jsid propid = props[i];
jsval propname, propval;
if (!JS_IdToValue(cx, propid, &propname) ||
!JS_GetPropertyById(cx, opts, propid, &propval)) {
continue;
!JS_GetPropertyById(cx, &opts, propid, &propval)) {
return NS_ERROR_FAILURE;
}
JSString *propnameString = JS_ValueToString(cx, propname);