Bug 805749, validate the view parameter of initUIEvent, r=jst

This commit is contained in:
Olli Pettay 2012-11-05 10:59:12 +02:00
Родитель 5d56c2ede7
Коммит 4d79fb7245
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -158,6 +158,10 @@ nsDOMUIEvent::InitUIEvent(const nsAString& typeArg,
nsIDOMWindow* viewArg,
int32_t detailArg)
{
if (viewArg) {
nsCOMPtr<nsPIDOMWindow> view = do_QueryInterface(viewArg);
NS_ENSURE_TRUE(view, NS_ERROR_INVALID_ARG);
}
nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -337,6 +337,24 @@ try {
ok(ex, "First parameter is required!");
ex = false;
try {
e = new UIEvent("foo", { view: {} });
e.view.onunload;
} catch(exp) {
ex = true;
}
ok(ex, "{} isn't a valid value.");
ex = false;
try {
e = new UIEvent("foo", { view: null });
} catch(exp) {
ex = true;
}
ok(!ex, "null is a valid value.");
is(e.view, null);
ex = false;
e = new UIEvent("hello");
ok(e.type, "hello", "Wrong event type!");
ok(!e.isTrusted, "Event shouldn't be trusted!");