Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: the browsing contexts must be sorted in the order that their containers were inserted into the Document</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#accessing-other-browsing-contexts" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t1 = async_test("The window's length must return the number of child browsing contexts(in iframe)");
function on_load1(fr) {
t1.step(function () {
var doc = fr.contentDocument;
var fr3 = doc.createElement("iframe");
fr3.setAttribute("id", "fr3");
doc.body.insertBefore(fr3, doc.getElementById("tbl"));
assert_equals(fr.contentWindow.length, 3, "The window.length should be 3.");
assert_array_equals([fr.contentWindow[0].frameElement, fr.contentWindow[1].frameElement, fr.contentWindow[2].frameElement],
[fr.contentDocument.getElementById("fr4"), fr.contentDocument.getElementById("fr5"), fr.contentDocument.getElementById("fr3")],
"The child browsing contexts must be sorted in the order that their containers were inserted into the Document.");
});
t1.done();
}
var t2 = async_test("The window's length must return zero if it has no child browsing context");
function on_load2(fr) {
t2.step(function () {
assert_equals(fr.contentWindow.length, 0, "The window.length should be 0.");
});
t2.done();
}
</script>
<iframe id="fr1" src="test1.html" style="display:none" onload="on_load1(this)"></iframe>
<iframe id="fr2" src="test2.html" style="display:none" onload="on_load2(this)"></iframe>
<script>
test(function () {
assert_equals(window.length, 2, "The window.length should be 2.");
assert_array_equals([window[0].frameElement, window[1].frameElement],
[document.getElementById("fr1"), document.getElementById("fr2")],
"The child browsing contexts must be sorted in the tree order.");
}, "The window's length must return the number of child browsing contexts");
</script>

View file

@ -0,0 +1,62 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>HTML Test: the browsing contexts created by various container elements</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t1 = async_test("Accessing child browsing contexts 1");
var t2 = async_test("Accessing child browsing contexts 2");
var t3 = async_test("Accessing child browsing contexts 3");
function on_load() {
//Child browsing contexts created by iframe, object and embed elements.
t1.step(function () {
assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts.");
});
t1.step(function () {
assert_equals(window[0].name, "win1", "The browsing context name should be 'win1'.");
assert_equals(window[1].name, "win2", "The browsing context name should be 'win2'.");
assert_equals(window[2].name, "win3", "The browsing context name should be 'win3'.");
});
t1.done();
//Child browsing contexts created by frame elements.
t2.step(function () {
assert_equals(document.getElementById("fr").contentWindow.length, 2,
"The child browsing context created by the iframe element should have 2 child browsing contexts.");
});
t2.step(function () {
assert_equals(document.getElementById("fr").contentWindow[0].name, "win4",
"The browsing context name should be 'win4'.");
assert_equals(document.getElementById("fr").contentWindow[1].name, "win5",
"The browsing context name should be 'win5'.");
});
t2.done();
//The child browsing context will be removed if the data attribute of the associated object element is removed.
t3.step(function () {
document.getElementById("obj").removeAttribute("type");
assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts.");
document.getElementById("obj").removeAttribute("data");
assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts.");
setTimeout(function () {
assert_equals(window.length, 2, "The top browsing context should have 2 child browsing contexts.");
}, 1);
});
t3.done();
}
</script>
</head>
<body onload="on_load()">
<div id="log"></div>
<div style="display:none">
<iframe id="fr" name="win1" src="test3.html"></iframe>
<object id="obj" name="win2" type="text/html" data="about:blank"></object>
<object type="image/png" src="/images/green.png"></object>
<embed id="emb" name="win3" type="image/svg+xml" src="/images/green.svg"></embed>
</div>
</body>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>HTML Test: indexed property of a Window object</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t1 = async_test("Indexed child browsing contexts");
function on_load() {
t1.step(function () {
assert_equals(window[0], document.getElementsByTagName("object")[0].contentWindow,
"The first child browsing context's container should be the object element.");
assert_equals(window[1], document.getElementsByTagName("iframe")[0].contentWindow,
"The second child browsing context's container should be the iframe element.");
});
t1.done();
}
</script>
</head>
<body onload="on_load()">
<div id="log"></div>
<div style="display:none">
<div id="0"></div>
<object name="0" type="text/html" data="test2.html"></object>
<iframe name="0" src="about:blank"></iframe>
</div>
</body>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: child browsing contexts created by iframe elements</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<table id="tbl">
<tr>
<td>
<iframe id="fr4" src=""></iframe>
</td>
</tr>
<iframe id="fr5" src="about:blank"></iframe>
</table>

View file

@ -0,0 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: child browsing contexts created by object and embed elements</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<object type="image/png" src="/images/green.png"></object>
<embed type="image/png" src="/images/green.png"></embed>

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: child browsing contexts created by frame elements</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<frameset>
<frame name="win4"></frame>
<frame name="win5"></frame>
</frameset>

View file

@ -0,0 +1,38 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[Browsing Context] : [APIs for creating browsing_contexts by name]</title>
<link rel="author" title="Duhyeong Kim" href="mailto:dduskim@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(function() {
var currentUrl = 'http://' + window.location.host + '/';
var win = window.open(currentUrl, '', 'height=1,width=1');
this.add_cleanup(function() { win.close(); });
win.onload = this.step_func_done(function () {
assert_equals(win.location.href, currentUrl, 'should be equal to result url');
});
}, 'first argument: absolute url');
test(function() {
var win = window.open('', '', 'height=1,width=1');
this.add_cleanup(function() { win.close(); });
assert_equals(win.location.href, 'about:blank', 'win.location.href');
}, 'first argument: empty url');
test(function () {
var win = window.open('', 'testWindow', 'height=1,width=1');
win.close();
assert_equals(win.name, 'testWindow', 'should have a browsing context name');
}, 'second argument: passing a non-empty name');
test(function () {
var win = window.open('', '', 'height=1,width=1');
this.add_cleanup(function() { win.close(); });
assert_equals(win.name, '', 'window should not have a name');
win.name = 'testWindow';
assert_equals(win.name, 'testWindow', 'window should have a name');
}, 'second argument: setting name after opening');
</script>

View file

@ -0,0 +1,80 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Named access on the Window object</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#named-access-on-the-window-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div style="display:none">
<p name="a" id="p1"></p>
<a name="a" id="a1" href="#"></a>
<applet name="a" id="app1"></applet>
<area name="a" id="area1"></area>
<embed name="a" id="embed1"></embed>
<form name="a" id="form1"></form>
<img name="a" id="img1">
<object name="a" id="obj1"></object>
<span name="a" id="span1"></span>
<b id="b" name="c"></b>
<a name="c"></a>
<iframe name="c" id="fm1"></iframe>
<iframe name="c" id="fm2" src="test.html" onload="on_load()"></iframe>
<input id="b"></input>
<span id="d"></span>
<a name=""></a>
<b id=""></b>
</div>
<script>
test(function() {
assert_equals(window['c'], document.getElementById("fm1").contentWindow, "The first iframe's window should be returned.");
}, "Check if the first nested browsing context is returned by window['c']");
test(function() {
assert_equals(window['a'].length, 7, "The length should be 7.");
assert_true(window['a'] instanceof HTMLCollection);
assert_array_equals(window['a'],
[ document.getElementById('a1'), document.getElementById('app1'),
document.getElementById('area1'), document.getElementById('embed1'),
document.getElementById('form1'), document.getElementById('img1'),
document.getElementById('obj1') ],
"The elements are not in tree order.");
document.getElementById('a1').setAttribute("name", "");
document.getElementById('area1').setAttribute("name", "");
assert_array_equals(window['a'],
[ document.getElementById('app1'), document.getElementById('embed1'),
document.getElementById('form1'), document.getElementById('img1'),
document.getElementById('obj1') ],
"Window['a'] should not contain the elements with empty name attribute.");
}, "Check if window['a'] contains all a, applet, area, embed, form, img, and object elements, and their order");
var t = async_test("Check if window['fs'] return the frameset element with name='fs'");
function on_load () {
t.step(function () {
assert_equals(document.getElementById('fm2').contentWindow['fs'],
document.getElementById('fm2').contentDocument.getElementById('fs1'),
"The frameset element should be returned.");
});
t.done();
}
test(function() {
assert_true(window['b'] instanceof HTMLCollection);
assert_array_equals(window['b'], [document.getElementsByTagName('b')[0], document.getElementsByTagName('input')[0]]);
document.getElementsByTagName('b')[0].setAttribute("id", "");
assert_equals(window['b'], document.getElementsByTagName('input')[0],
"The window['b'] should not contain the elements with empty id attribute.");
}, "Check if window['b'] returns the elements with the id='b'");
test(function() {
assert_equals(window['d'], document.getElementById('d'));
}, "Check if window['d'] returns the element with id='d'");
test(function() {
assert_equals(window[''], undefined, "The window[''] should be undefined");
}, "Check widow[''] when there are some elements with empty id or name attribute");
</script>

View file

@ -0,0 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Named Object</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<frameset name="fs" id="fs1">
<frame></frame>
</frameset>

View file

@ -0,0 +1,20 @@
<!doctype html>
<meta charset=utf-8>
<title>Named access with null characters</title>
<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-nameditem">
<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function() {
var iframe = document.createElement("iframe")
iframe.name = "a\0b"
document.body.appendChild(iframe)
assert_equals(window["a\0b"], iframe.contentWindow)
assert_equals(window["ab"], undefined)
assert_equals(window["a"], undefined)
});
</script>

View file

@ -0,0 +1,194 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: Window Security</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#the-window-object" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/timers.html#timers" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/webappapis.html#atob" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowsessionstorage" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowlocalstorage" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#window" />
<link rel="help" href="http://dev.w3.org/csswg/cssom/#extensions-to-the-window-interface" />
<link rel="help" href="http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe id="fr" src="http://{{domains[www1]}}:{{ports[http][0]}}/" onload="fr_load()" style="display:none"></iframe>
<script>
var t = async_test("Window Security testing");
function fr_load() {
fr = document.getElementById("fr");
t.step(function () {
//SecurityError should be thrown
[
//attributes
{name: "applicationCache"},
{name: "devicePixelRatio"},
{name: "document"},
{name: "external"},
{name: "frameElement"},
{name: "history"},
{name: "innerWidth"},
{name: "innerHeight"},
{name: "locationbar"},
{name: "localStorage"},
{name: "menubar"},
{name: "name"},
{name: "navigator"},
{name: "onabort"},
{name: "onafterprint"},
{name: "onbeforeprint"},
{name: "onbeforeunload"},
{name: "onblur"},
{name: "oncancel"},
{name: "oncanplay"},
{name: "oncanplaythrough"},
{name: "onchange"},
{name: "onclick"},
{name: "onclose"},
{name: "oncontextmenu"},
{name: "oncuechange"},
{name: "ondblclick"},
{name: "ondrag"},
{name: "ondragend"},
{name: "ondragenter"},
{name: "ondragleave"},
{name: "ondragover"},
{name: "ondragstart"},
{name: "ondrop"},
{name: "ondurationchange"},
{name: "onemptied"},
{name: "onended"},
{name: "onerror"},
{name: "onfocus"},
{name: "onhashchange"},
{name: "oninput"},
{name: "oninvalid"},
{name: "onkeydown"},
{name: "onkeypress"},
{name: "onkeyup"},
{name: "onload"},
{name: "onloadeddata"},
{name: "onloadedmetadata"},
{name: "onloadstart"},
{name: "onmessage"},
{name: "onmousedown"},
{name: "onmousemove"},
{name: "onmouseout"},
{name: "onmouseover"},
{name: "onmouseup"},
{name: "onmousewheel"},
{name: "onoffline"},
{name: "ononline"},
{name: "onpause"},
{name: "onplay"},
{name: "onplaying"},
{name: "onpagehide"},
{name: "onpageshow"},
{name: "onpopstate"},
{name: "onprogress"},
{name: "onratechange"},
{name: "onreset"},
{name: "onresize"},
{name: "onscroll"},
{name: "onseeked"},
{name: "onseeking"},
{name: "onselect"},
{name: "onshow"},
{name: "onstalled"},
{name: "onstorage"},
{name: "onsubmit"},
{name: "onsuspend"},
{name: "ontimeupdate"},
{name: "onunload"},
{name: "onvolumechange"},
{name: "onwaiting"},
{name: "pageXOffset"},
{name: "pageYOffset"},
{name: "personalbar"},
{name: "screen"},
{name: "scrollbars"},
{name: "statusbar"},
{name: "status"},
{name: "screenX"},
{name: "screenY"},
{name: "sessionStorage"},
{name: "toolbar"},
//methods
{name: "alert", isMethod: true},
{name: "clearInterval", isMethod: true, args:[1]},
{name: "clearTimeout", isMethod: true, args:[function () {}, 1]},
{name: "confirm", isMethod: true},
{name: "getComputedStyle", isMethod: true, args:[document.body, null]},
{name: "getSelection", isMethod: true},
{name: "matchMedia", isMethod: true, args:["(min-width:50px)"]},
{name: "moveBy", isMethod: true, args:[10, 10]},
{name: "moveTo", isMethod: true, args:[10, 10]},
{name: "open", isMethod: true},
{name: "print", isMethod: true},
{name: "prompt", isMethod: true},
{name: "resizeTo", isMethod: true, args:[10, 10]},
{name: "resizeBy", isMethod: true, args:[10, 10]},
{name: "scroll", isMethod: true, args:[10, 10]},
{name: "scrollTo", isMethod: true, args:[10, 10]},
{name: "scrollBy", isMethod: true, args:[10, 10]},
{name: "setInterval", isMethod: true, args:[function () {}, 1]},
{name: "setTimeout", isMethod: true, args:[function () {}, 1]},
{name: "showModalDialog", isMethod: true, args:["auto:blank", "dialog"]},
{name: "stop", isMethod: true},
].forEach(function (item) {
test(function () {
assert_true(item.name in window, "window." + item.name + " should exist.");
assert_throws("SecurityError", function () {
if (item.isMethod)
if (item.args)
fr.contentWindow[item.name](item.args[0], item.args[1]);
else
fr.contentWindow[item.name]();
else
fr.contentWindow[item.name];
}, "A SecurityError exception should be thrown.");
}, "A SecurityError exception must be thrown when window." + item.name + " is accessed from a different origin.");
});
//SecurityError should not be thrown
[
//attributes
{name: "closed"},
{name: "frames"},
{name: "length"},
{name: "location"},
{name: "opener"},
{name: "parent"},
{name: "self"},
{name: "top"},
{name: "window"},
//methods
{name: "blur", isMethod: true},
{name: "close", isMethod: true},
{name: "focus", isMethod: true},
{name: "postMessage", isMethod: true, args: [{msg: 'foo'}, "*"]}
].forEach(function (item) {
test(function () {
assert_true(item.name in window, "window." + item.name + " should exist.");
try {
if (item.isMethod)
if (item.args)
fr.contentWindow[item.name](item.args[0], item.args[1]);
else
fr.contentWindow[item.name]();
else
fr.contentWindow[item.name];
} catch (e) {
assert_unreached("An unexpected exception was thrown.");
}
}, "A SecurityError exception should not be thrown when window." + item.name + " is accessed from a different origin.");
});
});
t.done();
}
</script>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Window Proxy locationbar visible flag Test</title>
<link rel="author" title='JuneyoungOh' href="juneyoung85@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>WindowProxy.locationbar Test</p>
<h1>Manual Test Steps:</h1>
<ol>
<li>Make the locationbar visible in the user agent before executing this test.</li>
<li>You may need to manually reload afterwards.</li>
</ol>
<div id="log"></div>
<script>
test(function() {
assert_not_equals(typeof window.locationbar, undefined, 'window.locationbar is undefined');
assert_true(window.locationbar.visible)
}, "window.locationbar.visible");
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Window Proxy menubar visible flag Test</title>
<link rel="author" title='JuneyoungOh' href="juneyoung85@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>WindowProxy.menubar Test</p>
<h1>Manual Test Steps:</h1>
<ol>
<li>Make the menubar visible in the user agent before executing this test.</li>
<li>You may need to manually reload afterwards.</li>
</ol>
<div id="log"></div>
<script>
test(function() {
assert_not_equals(typeof window.menubar, undefined, 'window.menubar is undefined');
assert_true(window.menubar.visible);
}, "window.menubar.visible");
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Window Proxy personalbar visible flag Test</title>
<link rel="author" title="vanessa" href="mailto:vanessaohsy@gmail.com">
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>WindowProxy.personalbar Test</p>
<h1>Manual Test Steps:</h1>
<ol>
<li>Make the personalbar visible in the user agent before executing this test.</li>
<li>You may need to manually reload afterwards.</li>
</ol>
<div id="log"></div>
<script type="text/javascript" >
test(function () {
assert_not_equals(window.personalbar, undefined, "window.personalbar is undefined");
assert_true(window.personalbar.visible, "window.personalbar.visible");
});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Window Proxy scrollbars visible flag Test</title>
<link rel="author" title="vanessa" href="vanessaohsy@gmail.com">
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>WindowProxy.scrollbars Test</p>
<h1>Manual Test Steps:</h1>
<ol>
<li>Make the scrollbars visible in the user agent before executing this test.</li>
<li>You may need to manually reload afterwards.</li>
</ol>
<div id="log"></div>
<script type="text/javascript" >
test(function () {
assert_not_equals(window.scrollbars, undefined, "window.scrollbars is undefined");
assert_true(window.scrollbars.visible, "window.scrollbars.visible");
});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>WindowProxy statusbar visible flag Test</title>
<link rel="author" title="dokenzy" href="dokenzy@gmail.com">
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>WindowProxy.statusbar Test</p>
<h1>Manual Test Steps:</h1>
<ol>
<li>Make the statusbar visible in the user agent before executing this test.</li>
<li>You may need to manually reload afterwards.</li>
</ol>
<div id="log"></div>
<script type="text/javascript" >
test(function () {
assert_not_equals(typeof window.statusbar.visible, undefined, 'window.statusbar.visible');
assert_true(window.statusbar.visible, 'window.statusbar.visible');
}, "BarProp attribute: window.statusbar.visible");
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>WindowProxy toolbar visible flag Test</title>
<link rel="author" title="dokenzy" href="dokenzy@gmail.com">
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>Description</h1>
<p>WindowProxy.toolbar Test</p>
<h1>Manual Test Steps:</h1>
<ol>
<li>Make the toolbar visible in the user agent before executing this test.</li>
<li>You may need to manually reload afterwards.</li>
</ol>
<div id="log"></div>
<script type="text/javascript" >
test(function () {
assert_not_equals(typeof window.toolbar.visible, undefined, 'window.toolbar.visible');
assert_true(window.toolbar.visible, 'window.toolbar.visible');
}, "BarProp attribute: window.toolbar.visible");
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!doctype html>
<meta charset=utf-8>
<title>Aliases of the window object</title>
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-frames">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-self">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var global = this;
test(function() {
assert_equals(window, global);
assert_equals(window.window, global);
}, "window should be the global object");
test(function() {
assert_equals(frames, global);
assert_equals(window.frames, global);
}, "frames should be the global object");
test(function() {
assert_equals(self, global);
assert_equals(window.self, global);
}, "self should be the global object");
</script>

View file

@ -0,0 +1,43 @@
<!doctype html>
<meta charset=utf-8>
<title>Indexed properties of the window object (strict mode)</title>
<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-item">
<link rel="help" href="https://heycam.github.io/webidl/#getownproperty">
<link rel="help" href="https://heycam.github.io/webidl/#defineownproperty">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<iframe></iframe>
<script>
test(function() {
"use strict";
assert_false("-1" in window, "-1 not in window");
assert_equals(window[-1], undefined);
window[-1] = "foo";
assert_equals(window[-1], "foo");
});
test(function() {
"use strict";
assert_throws(new TypeError(), function() {
window[0] = "foo";
});
assert_equals(window[0],
document.getElementsByTagName("iframe")[0].contentWindow);
});
test(function() {
"use strict";
assert_throws(new TypeError(), function() {
window[1] = "foo";
});
assert_equals(window[1], undefined);
});
test(function() {
"use strict";
var proto = Window.prototype;
[-1, 0, 1].forEach(function(idx) {
assert_false(idx in proto, idx + " in proto");
});
});
</script>

View file

@ -0,0 +1,35 @@
<!doctype html>
<meta charset=utf-8>
<title>Indexed properties of the window object (non-strict mode)</title>
<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-item">
<link rel="help" href="https://heycam.github.io/webidl/#getownproperty">
<link rel="help" href="https://heycam.github.io/webidl/#defineownproperty">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<iframe></iframe>
<script>
test(function() {
assert_false("-1" in window, "-1 not in window");
assert_equals(window[-1], undefined);
window[-1] = "foo";
assert_equals(window[-1], "foo");
});
test(function() {
window[0] = "foo";
assert_equals(window[0],
document.getElementsByTagName("iframe")[0].contentWindow);
});
test(function() {
window[1] = "foo";
assert_equals(window[1], undefined);
});
test(function() {
var proto = Window.prototype;
[-1, 0, 1].forEach(function(idx) {
assert_false(idx in proto, idx + " in proto");
});
});
</script>

View file

@ -0,0 +1,70 @@
<!doctype html>
<meta charset=utf-8>
<title>Changes to named properties of the window object</title>
<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
<link rel="author" title="Boris Zbarsky" href="bzbarsky@mit.edu">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-nameditem">
<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<iframe name="bar"></iframe>
<iframe name="constructor"></iframe>
<script>
function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
assert_equals(typeof pd, "object");
assert_equals(pd.writable, Writable);
assert_equals(pd.enumerable, Enumerable);
assert_equals(pd.configurable, Configurable);
}
test(function() {
assert_true("bar" in window, "bar not in window");
assert_equals(window["bar"],
document.getElementsByTagName("iframe")[0].contentWindow);
}, "Static name");
test(function() {
assert_true("bar" in Window.prototype, "bar in Window.prototype");
assert_false(Window.prototype.hasOwnProperty("bar"), "Window.prototype.hasOwnProperty(\"bar\")");
var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window));
assert_true("bar" in gsp, "bar in gsp");
assert_true(gsp.hasOwnProperty("bar"), "gsp.hasOwnProperty(\"bar\")");
assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "bar"),
false, true, true);
}, "Static name on the prototype");
test(function() {
assert_equals(window.constructor, Window);
assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
var proto = Object.getPrototypeOf(window);
assert_equals(proto.constructor, Window);
assert_true("constructor" in proto, "constructor in proto");
assert_data_propdesc(Object.getOwnPropertyDescriptor(proto, "constructor"),
true, false, true);
var gsp = Object.getPrototypeOf(proto);
assert_true("constructor" in gsp, "constructor in gsp");
assert_true(gsp.hasOwnProperty("constructor"), "gsp.hasOwnProperty(\"constructor\")");
assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "constructor"),
false, true, true);
}, "constructor");
var t = async_test("Dynamic name")
var t2 = async_test("Ghost name")
t.step(function() {
var iframe = document.getElementsByTagName("iframe")[0];
iframe.setAttribute("src", "data:text/html,<script>window.name='foo'<\/script>");
iframe.onload = function() {
t.step(function() {
assert_true("foo" in window, "foo not in window");
assert_equals(window["foo"], iframe.contentWindow);
});
t.done();
t2.step(function() {
assert_false("bar" in window, "bar still in window");
assert_equals(window["bar"], undefined);
});
t2.done();
};
});
</script>

View file

@ -0,0 +1,322 @@
<!doctype html>
<meta charset=utf-8>
<title>Properties of the window object</title>
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
<link rel="help" href="http://ecma-international.org/ecma-262/5.1/#sec-15.1">
<link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-object">
<link rel="help" href="https://heycam.github.io/webidl/#es-attributes">
<link rel="help" href="https://heycam.github.io/webidl/#es-operations">
<link rel="help" href="https://dom.spec.whatwg.org/#eventtarget">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowtimers">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowbase64">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowsessionstorage">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#windowlocalstorage">
<link rel="help" href="https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-window-getselection">
<link rel="help" href="http://dev.w3.org/csswg/cssom/#widl-def-Window">
<link rel="help" href="http://dev.w3.org/csswg/cssom-view/#widl-def-Window">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
assert_equals(typeof pd, "object");
assert_equals(pd.writable, Writable);
assert_equals(pd.enumerable, Enumerable);
assert_equals(pd.configurable, Configurable);
}
function assert_accessor_propdesc(pd, hasSetter, Enumerable, Configurable) {
assert_equals(typeof pd, "object");
assert_equals(typeof pd.get, "function");
assert_true("set" in pd,
"Should always have a setter property on the property descriptor");
assert_equals(typeof pd.set, hasSetter ? "function" : "undefined");
assert_equals(pd.enumerable, Enumerable);
assert_equals(pd.configurable, Configurable);
}
var unforgeableAttributes = [
"window",
"document",
"location",
"top"
];
var replacableAttributes = [
"self",
"locationbar",
"menubar",
"personalbar",
"scrollbars",
"statusbar",
"toolbar",
"frames",
"length"
];
var methods = [
"close",
"stop",
"focus",
"blur",
"open",
"alert",
"confirm",
"prompt",
"print",
// See below: "showModalDialog",
"postMessage",
// WindowBase64
"btoa",
"atob",
// WindowTimers
"setTimeout",
"clearTimeout",
"setInterval",
"clearInterval",
// HTML Editing APIs
"getSelection",
// CSSOM
"getComputedStyle",
// CSSOM-View
"matchMedia",
"scroll",
"scrollTo",
"scrollBy"
];
// We would like to remove showModalDialog from the platform,
// see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=26437>.
if ("showModalDialog" in window) {
methods.push("showModalDialog");
}
var readonlyAttributes = [
"history",
"parent",
"frameElement",
"navigator",
"external",
"applicationCache",
// WindowSessionStorage
"sessionStorage",
// WindowLocalStorage
"localStorage",
// CSSOM-View
"screen",
"innerWidth",
"innerHeight",
"scrollX",
"pageXOffset",
"scrollY",
"pageYOffset",
"screenX",
"screenY",
"outerWidth",
"outerHeight"
];
var writableAttributes = [
"name",
"status",
"opener",
"onabort",
"onafterprint",
"onbeforeprint",
"onbeforeunload",
"onblur",
"oncancel",
"oncanplay",
"oncanplaythrough",
"onchange",
"onclick",
"onclose",
"oncontextmenu",
"oncuechange",
"ondblclick",
"ondrag",
"ondragend",
"ondragenter",
"ondragleave",
"ondragover",
"ondragstart",
"ondrop",
"ondurationchange",
"onemptied",
"onended",
"onerror",
"onfocus",
"onhashchange",
"oninput",
"oninvalid",
"onkeydown",
"onkeypress",
"onkeyup",
"onload",
"onloadeddata",
"onloadedmetadata",
"onloadstart",
"onmessage",
"onmousedown",
"onmousemove",
"onmouseout",
"onmouseover",
"onmouseup",
"onmousewheel",
"onoffline",
"ononline",
"onpause",
"onplay",
"onplaying",
"onpagehide",
"onpageshow",
"onpopstate",
"onprogress",
"onratechange",
"onreset",
"onresize",
"onscroll",
"onseeked",
"onseeking",
"onselect",
"onshow",
"onstalled",
"onstorage",
"onsubmit",
"onsuspend",
"ontimeupdate",
"onunload",
"onvolumechange",
"onwaiting"
];
test(function() {
// 15.1.1 Value Properties of the Global Object
["NaN", "Infinity", "undefined"].forEach(function(id) {
test(function() {
assert_true(id in window, id + " in window");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
false, false, false);
}, "Value Property: " + id);
});
}, "Value Properties of the Global Object");
test(function() {
// 15.1.2 Function Properties of the Global Object
["eval", "parseInt", "parseFloat", "isNaN", "isFinite"].forEach(function(id) {
test(function() {
assert_true(id in window, id + " in window");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, false, true);
}, "Function Property: " + id);
});
}, "Function Properties of the Global Object");
test(function() {
// 15.1.3 URI Handling Function Properties
["decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent"].forEach(function(id) {
test(function() {
assert_true(id in window, id + " in window");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, false, true);
}, "URI Handling Function Property: " + id);
});
}, "URI Handling Function Properties");
test(function() {
// 15.1.4 Constructor Properties of the Global Object
["Object", "Function", "Array", "String", "Boolean", "Number", "Date",
"RegExp", "Error", "EvalError", "RangeError", "ReferenceError",
"SyntaxError", "TypeError", "URIError"].forEach(function(id) {
test(function() {
assert_true(id in window, id + " in window");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, false, true);
}, "Constructor Property: " + id);
});
}, "Constructor Properties of the Global Object");
test(function() {
// 15.1.5 Other Properties of the Global Object
["Math", "JSON"].forEach(function(id) {
test(function() {
assert_true(id in window, id + " in window");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, false, true);
}, "Other Property: " + id);
});
}, "Other Properties of the Global Object");
test(function() {
// EventTarget interface
["addEventListener", "removeEventListener", "dispatchEvent"].forEach(function(id) {
test(function() {
var EventTargetProto = EventTarget.prototype;
assert_true(id in window, id + " in window");
assert_equals(window[id], EventTargetProto[id]);
assert_data_propdesc(Object.getOwnPropertyDescriptor(EventTargetProto, id),
true, true, true);
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, true, true);
}, "EventTarget method: " + id);
});
}, "EventTarget interface");
test(function() {
// Window interface
methods.forEach(function(id) {
test(function() {
var WindowProto = Window.prototype;
assert_true(id in window, id + " in window");
assert_false(id in WindowProto, id + " in Window.prototype");
assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, true, true);
}, "Window method: " + id);
});
readonlyAttributes.forEach(function(id) {
test(function() {
var WindowProto = Window.prototype;
assert_true(id in window, id + " in window");
assert_false(id in WindowProto, id + " in Window.prototype");
assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
false, true, true);
}, "Window readonly attribute: " + id);
});
writableAttributes.forEach(function(id) {
test(function() {
var WindowProto = Window.prototype;
assert_true(id in window, id + " in window");
assert_false(id in WindowProto, id + " in Window.prototype");
assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, true, true);
}, "Window attribute: " + id);
});
unforgeableAttributes.forEach(function(id) {
test(function() {
var WindowProto = Window.prototype;
assert_true(id in window, id + " in window");
assert_false(id in WindowProto, id + " in Window.prototype");
// location has a [PutForwards] extended attribute.
assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
id === "location", true, false);
}, "Window unforgeable attribute: " + id);
});
replacableAttributes.forEach(function(id) {
test(function() {
var WindowProto = Window.prototype;
assert_true(id in window, id + " in window");
assert_false(id in WindowProto, id + " in Window.prototype");
assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
true, true, true);
}, "Window replaceable attribute: " + id);
});
}, "Window interface");
test(function() {
assert_equals(window.constructor, Window);
assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
assert_data_propdesc(Object.getOwnPropertyDescriptor(Window.prototype, "constructor"),
true, false, true);
}, "constructor");
</script>

View file

@ -0,0 +1,35 @@
<!doctype html>
<meta charset=utf-8>
<title>Prototype chain of the window object</title>
<link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
<link rel="help" href="https://dom.spec.whatwg.org/#eventtarget">
<link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-object">
<link rel="help" href="https://heycam.github.io/webidl/#named-properties-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function() {
assert_class_string(window, "Window");
}, "window object");
test(function() {
var proto = Object.getPrototypeOf(window);
assert_class_string(proto, "WindowPrototype");
assert_equals(proto, Window.prototype);
}, "Window.prototype");
test(function() {
var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window));
assert_class_string(gsp, "WindowProperties");
}, "Global scope polluter");
test(function() {
var protoproto = Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(window)));
assert_class_string(protoproto, "EventTargetPrototype");
assert_equals(protoproto, EventTarget.prototype);
}, "EventTarget.prototype");
test(function() {
var protoprotoproto = Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(window))));
assert_class_string(protoprotoproto, "Object");
assert_equals(protoprotoproto, Object.prototype);
}, "Object.prototype");
</script>