Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326

This commit is contained in:
Josh Matthews 2017-10-12 09:25:50 -04:00
parent 462c272380
commit 1f531f66ea
5377 changed files with 174916 additions and 84369 deletions

View file

@ -5,12 +5,6 @@
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function () {
var e = document.createEvent('PopStateEvent');
var eProto = Object.getPrototypeOf(e);
assert_equals(eProto, PopStateEvent.prototype);
}, 'document.createEvent');
test(function () {
assert_false('initPopStateEvent' in PopStateEvent.prototype,
'There should be no PopStateEvent#initPopStateEvent');

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<script>
var url = new URL(window.location.href);
url.hostname = "{{GET[hostname]}}";
url.pathname = "/html/browsers/browsing-the-web/history-traversal/support/window-name-test.sub.html";
url.search = "shouldhavename={{GET[shouldhavename]}}&sendmessage={{GET[sendmessage]}}";
window.name = "test";
document.location = url.href;
</script>
</html>

View file

@ -0,0 +1,23 @@
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script>
function process_test_result(passed, test_name) {
if ({{GET[sendmessage]}}) {
if (window.opener) {
window.opener.postMessage(passed, "*");
} else {
parent.postMessage(passed, "*");
}
} else {
test(function(t) {
assert_equals(passed, true);
}, test_name);
}
}
if ({{GET[shouldhavename]}}) {
process_test_result(window.name == "test", "Test that window name is present");
} else {
process_test_result(window.name == "", "Test that window name is not present");
}
</script>

View file

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<head>
<!-- window.name should equal "test" after a cross-origin auxiliary frame navigation. -->
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
t = async_test("Test that the window name is correct");
window.addEventListener("message", t.step_func_done(function(e) {
assert_equals(e.data, true);
}));
window.open("support/window-name-navigation.sub.html?hostname={{domains[www1]}}&shouldhavename=true&sendmessage=true");
</script>
</body>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<!-- window.name should equal "" after a cross-origin main frame navigation. -->
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
document.location = "support/window-name-navigation.sub.html?hostname={{domains[www1]}}&shouldhavename=false&sendmessage=false";
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<head>
<!-- window.name should equal "test" after a cross-origin sub frame navigation. -->
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
t = async_test("Test that the window name is correct");
window.addEventListener("message", t.step_func_done(function(e) {
assert_equals(e.data, true);
}));
</script>
<iframe src="support/window-name-navigation.sub.html?hostname={{domains[www1]}}&shouldhavename=true&sendmessage=true";
</iframe>
</body>
</html>

View file

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<head>
<!-- window.name should equal "test" after a same-origin auxiliary frame navigation. -->
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
t = async_test("Test that the window name is correct");
window.addEventListener("message", t.step_func_done(function(e) {
assert_equals(e.data, true);
}));
window.open("support/window-name-navigation.sub.html?hostname={{host}}&shouldhavename=true&sendmessage=true");
</script>
</body>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<!-- window.name should equal "test" after a same-origin main frame navigation. -->
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
document.location = "support/window-name-navigation.sub.html?hostname={{host}}&shouldhavename=true&sendmessage=false";
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<head>
<!-- window.name should equal "test" after a same-origin sub frame navigation. -->
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
t = async_test("Test that the window name is correct");
window.addEventListener("message", t.step_func_done(function(e) {
assert_equals(e.data, true);
}));
</script>
<iframe src="support/window-name-navigation.sub.html?hostname={{host}}&shouldhavename=true&sendmessage=true";
</iframe>
</body>
</html>

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Navigating forward after replace() should still trigger hashchange</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#history-traversal">
<link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola">
<!-- While writing ./replacement-enabled.html, a bug was discovered in Firefox where it does not
fire hashchange when using history.forward(), at least under certain conditions. So, this test
exercises that specifically. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="navigate-helpers.js"></script>
<body>
<script>
"use strict";
let resolve, iframe;
promise_test(() => {
iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.addEventListener("load", runTest);
document.body.appendChild(iframe);
return new Promise(r => resolve = r);
});
function runTest() {
iframe.removeEventListener("load", runTest);
const frameWindow = iframe.contentWindow;
resolve((async () => {
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#apple");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#banana");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#cat");
await navigateAndWaitForChange(frameWindow, w => w.history.back());
await navigateAndWaitForChange(frameWindow,
w => w.location.replace("/common/blank.html#zebra"));
await navigateAndWaitForChange(frameWindow, w => w.history.forward());
})());
}
</script>

View file

@ -0,0 +1,23 @@
"use strict";
// Usage examples:
// navigateAndWaitForChange(frameWindow, w => w.location.href = "...");
// navigateAndWaitForChange(frameWindow, w => w.history.back());
// navigateAndWaitForChange(frameWindow, w => w.history.back(), { assumeSuccessAfter: 100 });
window.navigateAndWaitForChange = (w, navigationAction, { assumeSuccessAfter } = {}) => {
return new Promise(resolve => {
w.addEventListener("hashchange", listener);
function listener() {
w.removeEventListener("hashchange", listener);
resolve();
}
if (assumeSuccessAfter !== undefined) {
step_timeout(resolve, assumeSuccessAfter);
}
navigationAction(w);
});
};

View file

@ -0,0 +1,69 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Navigating to a fragment should not clear forward history</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#scroll-to-fragid">
<link rel="help" href="https://github.com/whatwg/html/issues/2796">
<link rel="help" href="https://github.com/whatwg/html/pull/2869">
<link rel="author" href="mailto:d@domenic.me" title="Domenic Denicola">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="navigate-helpers.js"></script>
<body>
<script>
"use strict";
let resolve, iframe;
promise_test(() => {
iframe = document.createElement("iframe");
iframe.src = "/common/blank.html";
iframe.addEventListener("load", runTest);
document.body.appendChild(iframe);
return new Promise(r => resolve = r);
});
function runTest() {
iframe.removeEventListener("load", runTest);
const frameWindow = iframe.contentWindow;
resolve((async () => {
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#apple");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#banana");
await navigateAndWaitForChange(frameWindow, w => w.location.href = "/common/blank.html#cat");
assert_equals(frameWindow.location.hash, "#cat");
// Might not be 4 (= 3 for iframe + 1 initial) due to cross-browser differences or if people are
// running this test in a window that has previously been places. The important thing for this
// test is the delta from this value.
const afterThreeNavigations = frameWindow.history.length;
await navigateAndWaitForChange(frameWindow, w => w.history.back());
assert_equals(frameWindow.location.hash, "#banana");
assert_equals(frameWindow.history.length, afterThreeNavigations,
"back() must not change the history length");
await navigateAndWaitForChange(frameWindow,
w => w.location.replace("/common/blank.html#zebra"));
assert_equals(frameWindow.location.hash, "#zebra");
assert_equals(frameWindow.history.length, afterThreeNavigations,
"replace() must not change the history length");
// As of the time of this writing (2017-08-14), Firefox is not firing hashchange on forward, so
// we automatically assume navigation succeeded after 100 ms. A sibling test will test this
// particular Firefox bug.
await navigateAndWaitForChange(frameWindow, w => w.history.forward(),
{ assumeSuccessAfter: 100 });
assert_equals(frameWindow.location.hash, "#cat");
assert_equals(frameWindow.history.length, afterThreeNavigations,
"forward() must not change the history length");
})());
}
</script>

View file

@ -5,8 +5,9 @@
<script src="/resources/testharnessreport.js"></script>
<body>
<div></div>
<div id="has two spaces" style="position:absolute; top:200px;"></div>
<div id="escape%20collision" style="position:absolute; top:300px;"></div>
<div id="has two spaces" style="position:absolute; top:100px;"></div>
<div id="escape%20collision" style="position:absolute; top:200px;"></div>
<div id="%20has%20two%20spaces" style="position:absolute; top:300px;"></div>
<div id="escape collision" style="position:absolute; top:400px;"></div>
<div id="do%20not%20go%20here" style="position:absolute; top:400px;"></div>
<div style="height:200em;"></div>
@ -14,12 +15,18 @@
var steps = [{
fragid:'has%20two%20spaces',
handler: function(){
assert_equals( scrollPosition(), 200 );
assert_equals( scrollPosition(), 100 );
}
},{
fragid:'escape%20collision',
handler: function(){
assert_equals( scrollPosition(), 400 );
assert_equals( scrollPosition(), 200 );
document.getElementById("%20has%20two%20spaces").setAttribute("id", "has%20two%20spaces");
}
},{
fragid:'has%20two%20spaces',
handler: function(){
assert_equals( scrollPosition(), 300 );
}
},{
fragid:'do%20not%20go%20here',

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>history properties should throw SecurityError when not in a fully active Document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<iframe id="child"></iframe>
</body>
<script>
test(function(t) {
var ifr = document.getElementById("child");
var cached_history = ifr.contentWindow.history;
ifr.remove();
assert_throws("SecurityError", function() { cached_history.length; });
assert_throws("SecurityError", function() { cached_history.scrollRestoration; });
assert_throws("SecurityError", function() { cached_history.state; });
assert_throws("SecurityError", function() { cached_history.go(0); });
assert_throws("SecurityError", function() { cached_history.back(); });
assert_throws("SecurityError", function() { cached_history.forward(); });
assert_throws("SecurityError", function() { cached_history.pushState(1, document.title, "?x=1"); });
assert_throws("SecurityError", function() { cached_history.replaceState(2, document.title, "?x=2"); });
});
</script>

View file

@ -0,0 +1,81 @@
<html manifest="resources/appcache-worker.manifest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var resolveInitPromise;
var initPromise = new Promise(r => { resolveInitPromise = r; });
applicationCache.addEventListener('cached', resolveInitPromise, false);
applicationCache.addEventListener('noupdate', resolveInitPromise, false);
promise_test(t => {
return initPromise.then(_ => {
var worker =
new Worker('resources/appcache-worker.py?type=cached');
return new Promise(r => { worker.onmessage = r; });
}).then(event => {
assert_equals(event.data, 'Done: cached');
});
}, 'Dedicated worker of the cached script');
promise_test(t => {
return initPromise.then(_ => {
var worker =
new Worker('resources/appcache-worker.py?type=fallingback');
return new Promise(r => { worker.onmessage = r; });
}).then(event => {
assert_equals(event.data, 'Done: fallbacked');
});
}, 'Dedicated worker of the fallbacked script');
promise_test(t => {
return initPromise.then(_ => {
var worker =
new Worker('resources/appcache-dedicated-worker-not-in-cache.js');
return new Promise((resolve, reject) => {
worker.onerror = resolve;
worker.onmessage = _ => {
reject('The worker not in the AppCache must not be executed.');
};
});
});
}, 'Dedicated worker of the not-in-cache script');
promise_test(t => {
return initPromise.then(_ => {
var worker =
new SharedWorker('resources/appcache-worker.py?type=cached');
var promise = new Promise(r => { worker.port.onmessage = r; });
worker.port.start();
return promise;
}).then(event => {
assert_equals(event.data, 'Done: cached');
});
}, 'Shared worker of the cached script');
promise_test(t => {
return initPromise.then(_ => {
var worker =
new SharedWorker('resources/appcache-worker.py?type=fallingback');
var promise = new Promise(r => { worker.port.onmessage = r; });
worker.port.start();
return promise;
}).then(event => {
assert_equals(event.data, 'Done: fallbacked');
});
}, 'Shared worker of the fallbacked script');
promise_test(t => {
return initPromise.then(_ => {
var worker =
new SharedWorker(
'resources/appcache-shared-worker-not-in-cache.js');
var promise = new Promise(r => { worker.port.onmessage = r; });
worker.port.start();
return promise;
}).then(event => {
assert_equals(event.data, 'Done');
});
}, 'Shared worker of the not-in-cache script');
</script>
</html>

View file

@ -0,0 +1,64 @@
var info = '';
var initPromise = new Promise(resolve => {
self.addEventListener('connect', event => {
self.postMessage = msg => { event.ports[0].postMessage(msg); };
resolve();
});
});
function importNotInCacheSciptTest() {
return new Promise((resolve, reject) => {
try {
importScripts('appcache-worker-import.py?type=not-in-cache');
} catch(e) {
reject(new Error('Error while importing the not-in-cache script: ' +
e.toString()));
return;
}
if (info != 'Set by the not-in-cache script') {
reject(new Error('The not-in-cache script was not correctly executed'));
}
resolve();
});
}
function importFallbackSciptTest() {
return new Promise((resolve, reject) => {
try {
importScripts('appcache-worker-import.py?type=fallingback');
reject(new Error('Importing a fallback script must fail.'));
} catch(e) {
resolve();
}
});
}
function fetchNotInCacheFileTest() {
return fetch('appcache-worker-data.py?type=not-in-cache')
.then(res => res.text(),
_ => { throw new Error('Failed to fetch not-in-cache file'); })
.then(text => {
if (text != 'not-in-cache') {
throw new Error('not-in-cache file mismatch');
}
})
}
function fetchFallbackFileTest() {
return fetch('appcache-worker-data.py?type=fallingback')
.then(res => {
if (res.status != 404) {
throw new Error(
'Fetching fallback file must resolve with 404 response');
}
},
_ => { throw new Error('Fetching fallback file must not fail'); });
}
initPromise
.then(importNotInCacheSciptTest)
.then(importFallbackSciptTest)
.then(fetchNotInCacheFileTest)
.then(fetchFallbackFileTest)
.then(_ => postMessage('Done'), error => postMessage(error.toString()));

View file

@ -0,0 +1,5 @@
def main(request, response):
type = request.GET['type']
if request.GET['type'] == 'fallingback':
return 404, [('Content-Type', 'text/plain')], "Page not found"
return [('Content-Type', 'text/plain')], type

View file

@ -0,0 +1,7 @@
script = 'info = \'Set by the %s script\';'
def main(request, response):
type = request.GET['type']
if request.GET['type'] == 'fallingback':
return 404, [('Content-Type', 'text/plain')], "Page not found"
return [('Content-Type', 'text/javascript')], script % type

View file

@ -0,0 +1,10 @@
CACHE MANIFEST
appcache-worker.py?type=cached
appcache-worker-import.py?type=cached
appcache-worker-data.py?type=cached
FALLBACK:
appcache-worker.py?type=fallingback appcache-worker.py?type=fallbacked
appcache-worker-import.py?type=fallingback appcache-worker-import.py?type=fallbacked
appcache-worker-data.py?type=fallingback appcache-worker-data.py?type=fallbacked

View file

@ -0,0 +1,102 @@
script = '''
var initPromise = Promise.resolve();
if ('SharedWorkerGlobalScope' in self &&
self instanceof SharedWorkerGlobalScope) {
initPromise = new Promise(resolve => {
self.addEventListener('connect', event => {
self.postMessage = msg => { event.ports[0].postMessage(msg); };
resolve();
});
});
}
var info = '';
function importCachedScriptTest() {
return new Promise((resolve, reject) => {
info = '';
try {
importScripts('appcache-worker-import.py?type=cached');
} catch(e) {
reject(new Error('Error while importing the cached script: ' +
e.toString()));
return;
}
if (info != 'Set by the cached script') {
reject(new Error('The cached script was not correctly executed'));
}
resolve();
});
}
function importNotInCacheSciptTest() {
return new Promise((resolve, reject) => {
try {
importScripts('appcache-worker-import.py?type=not-in-cache');
reject(new Error('Importing a non-cached script must fail.'));
} catch(e) {
resolve();
}
});
}
function importFallbackSciptTest() {
return new Promise((resolve, reject) => {
info = '';
try {
importScripts('appcache-worker-import.py?type=fallingback');
} catch(e) {
reject(new Error('Error while importing the fallingback script: ' +
e.toString()));
}
if (info != 'Set by the fallbacked script') {
reject(new Error('The fallingback script was not correctly executed'));
}
resolve();
});
}
function fetchCachedFileTest() {
return fetch('appcache-worker-data.py?type=cached')
.then(res => res.text(),
_ => { throw new Error('Failed to fetch cached file'); })
.then(text => {
if (text != 'cached') {
throw new Error('cached file missmatch');
}
});
}
function fetchNotInCacheFileTest() {
return fetch('appcache-worker-data.py?type=not-in-cache')
.then(_ => { throw new Error('Fetching not-in-cache file must fail'); },
_ => {});
}
function fetchFallbackFileTest() {
return fetch('appcache-worker-data.py?type=fallingback')
.then(res => res.text(),
_ => { throw new Error('Failed to fetch fallingback file'); })
.then(text => {
if (text != 'fallbacked') {
throw new Error('fallbacked file miss match');
}
});
}
initPromise
.then(importCachedScriptTest)
.then(importNotInCacheSciptTest)
.then(importFallbackSciptTest)
.then(fetchCachedFileTest)
.then(fetchNotInCacheFileTest)
.then(_ => postMessage('Done: %s'),
error => postMessage(error.toString()));
'''
def main(request, response):
type = request.GET['type']
if request.GET['type'] == 'fallingback':
return 404, [('Content-Type', 'text/plain')], "Page not found"
return [('Content-Type', 'text/javascript')], script % type

View file

@ -187,14 +187,16 @@ function checkPropertyDescriptor(desc, propName, expectWritable) {
var isSymbol = (typeof(propName) == "symbol");
propName = String(propName);
assert_true(isObject(desc), "property descriptor for " + propName + " should exist");
assert_equals(desc.enumerable, false, "property descriptor for " + propName + " should be non-enumerable");
assert_equals(desc.configurable, true, "property descriptor for " + propName + " should be configurable");
if (isSymbol) {
assert_equals(desc.enumerable, false, "symbol-property descriptor for " + propName + " should not be enumerable");
assert_true("value" in desc,
"property descriptor for " + propName + " should be a value descriptor");
assert_equals(desc.value, undefined,
"symbol-named cross-origin visible prop " + propName +
" should come back as undefined");
} else {
assert_equals(desc.enumerable, true, "property descriptor for " + propName + " should be enumerable");
}
if ('value' in desc)
assert_equals(desc.writable, expectWritable, "property descriptor for " + propName + " should have writable: " + expectWritable);
@ -256,15 +258,23 @@ addTest(function() {
}, "[[DefineOwnProperty]] Should throw for cross-origin objects");
/*
* [[Enumerate]]
* EnumerateObjectProperties (backed by [[OwnPropertyKeys]])
*/
addTest(function() {
for (var prop in C)
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
for (var prop in C.location)
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
}, "[[Enumerate]] should return an empty iterator");
let i = 0;
for (var prop in C) {
i++;
assert_true(whitelistedWindowPropNames.includes(prop), prop + " is not safelisted for a cross-origin Window");
}
assert_equals(i, whitelistedWindowPropNames.length, "Enumerate all safelisted cross-origin Window properties");
i = 0;
for (var prop in C.location) {
i++;
assert_true(whitelistedLocationPropNames.includes(prop), prop + " is not safelisted for a cross-origin Location");
}
assert_equals(i, whitelistedLocationPropNames.length, "Enumerate all safelisted cross-origin Location properties");
}, "Can only enumerate safelisted properties");
/*
* [[OwnPropertyKeys]]
@ -274,9 +284,15 @@ addTest(function() {
assert_array_equals(Object.getOwnPropertyNames(C).sort(),
whitelistedWindowPropNames,
"Object.getOwnPropertyNames() gives the right answer for cross-origin Window");
assert_array_equals(Object.keys(C).sort(),
whitelistedWindowPropNames,
"Object.keys() gives the right answer for cross-origin Window");
assert_array_equals(Object.getOwnPropertyNames(C.location).sort(),
whitelistedLocationPropNames,
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
assert_array_equals(Object.keys(C.location).sort(),
whitelistedLocationPropNames,
"Object.keys() gives the right answer for cross-origin Location");
}, "[[OwnPropertyKeys]] should return all properties from cross-origin objects");
addTest(function() {

View file

@ -37,6 +37,6 @@
<body>
<!-- Two subframes to give us some indexed properties -->
<iframe></iframe>
<iframe></iframe>
<iframe name=donotleakme></iframe><!-- "donotleakme" is excluded as cross-origin named property due to [[HideFromKeys]] -->
</body>
</html>

View file

@ -10,17 +10,28 @@
<body>
<script>
async_test(function (t) {
window.addEventListener("message", t.step_func_done(function (e) {
assert_equals(e.origin, "null", "Messages sent from a 'data:' URL should have an opaque origin (which serializes to 'null').");
assert_throws("SecurityError", function () {
var couldAccessCrossOriginProperty = e.source.location.href;
}, "The 'data:' frame should be cross-origin.")
}));
var i = document.createElement('iframe');
i.src = "data:text/html,<script>" +
" window.parent.postMessage('Hello!', '*');" +
"</scr" + "ipt>";
window.addEventListener("message", t.step_func_done(function (e) {
assert_equals(e.origin, "null", "Messages sent from a 'data:' URL should have an opaque origin (which serializes to 'null').");
assert_throws("SecurityError", function () {
var couldAccessCrossOriginProperty = e.source.location.href;
}, "The 'data:' frame should be cross-origin: 'window.location.href'");
// Try to access contentDocument of the 'data: ' frame. Some browsers
// (i.e. Firefox, Safari) will return |null| and some (i.e. Chrome)
// will throw an exception.
var dataFrameContentDocument = null;
try {
dataFrameContentDocument = i.contentDocument;
} catch (ex) {
}
assert_equals(dataFrameContentDocument, null, "The 'data:' iframe should be unable to access its contentDocument.");
}));
document.body.appendChild(i);
}, "The origin of a 'data:' document in a frame is opaque.");
</script>

View file

@ -9,7 +9,6 @@
<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>
@ -33,10 +32,9 @@ test(function() {
}, "Check if the first nested browsing context is returned by window['c']");
test(function() {
assert_equals(window['a'].length, 5, "The length should be 5.");
assert_true(window['a'] instanceof HTMLCollection);
assert_array_equals(window['a'],
[ document.getElementById('app1'), document.getElementById('embed1'),
[ document.getElementById('embed1'),
document.getElementById('form1'), document.getElementById('img1'),
document.getElementById('obj1') ],
"The elements are not in tree order.");
@ -44,10 +42,10 @@ test(function() {
document.getElementById('form1').setAttribute("name", "");
document.getElementById('embed1').setAttribute("name", "");
assert_array_equals(window['a'],
[ document.getElementById('app1'), document.getElementById('img1'),
[ document.getElementById('img1'),
document.getElementById('obj1') ],
"Window['a'] should not contain the elements with empty name attribute.");
}, "Check if window['a'] contains all applet, embed, form, img, and object elements, and their order");
}, "Check if window['a'] contains all embed, form, img, and object elements, and their order");
var t = async_test("Check that window['fs'] does not return the frameset element with name='fs' (historical)");
function on_load () {

View file

@ -17,6 +17,12 @@ test(function() {
window[-1] = "foo";
assert_equals(window[-1], "foo");
});
test(() => {
const desc = Object.getOwnPropertyDescriptor(window, "0");
assert_true(desc.configurable);
assert_true(desc.enumerable);
assert_false(desc.writable);
}, "Ensure indexed properties have the correct configuration");
test(function() {
window[0] = "foo";
assert_throws(new TypeError(), () => Object.defineProperty(window, 0, { value: "bar" }))

View file

@ -60,7 +60,7 @@ 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.setAttribute("srcdoc", "<script>window.name='foo'<\/script>");
iframe.onload = function() {
t.step(function() {
assert_true("foo" in window, "foo not in window");