blob: 71c8045a9bb3b9f9850f655bc1a12314ce3ee739 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests the constructor for the BeforeLoadEvent DOM class.");
// No initializer is passed.
shouldBe("new BeforeLoadEvent('eventType').bubbles", "false");
shouldBe("new BeforeLoadEvent('eventType').cancelable", "false");
shouldBeEqualToString("new BeforeLoadEvent('eventType').url", "");
// bubbles is passed.
shouldBe("new BeforeLoadEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new BeforeLoadEvent('eventType', { bubbles: true }).bubbles", "true");
// cancelable is passed.
shouldBe("new BeforeLoadEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new BeforeLoadEvent('eventType', { cancelable: true }).cancelable", "true");
// url is passed.
// Strings.
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: 'doremi' }).url", "doremi");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: '' }).url", "");
// Non-strings.
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: undefined }).url", "");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: null }).url", "null");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: false }).url", "false");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: true }).url", "true");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: 12345 }).url", "12345");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: 18446744073709551615 }).url", "18446744073709552000");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: NaN }).url", "NaN");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: [] }).url", "");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: [1, 2, 3] }).url", "1,2,3");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: {doremi: 12345} }).url", "[object Object]");
shouldBeEqualToString("new BeforeLoadEvent('eventType', { url: {valueOf: function () { return 'doremi'; } } }).url", "[object Object]");
// All initializers are passed.
shouldBe("new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).bubbles", "true");
shouldBe("new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).cancelable", "true");
shouldBe("new BeforeLoadEvent('eventType', { bubbles: true, cancelable: true, url: 'doremi' }).url", "'doremi'");
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>