Auto merge of #20911 - servo-wpt-sync:wpt_update_03-06-2018, r=jdm

Sync WPT with upstream (03-06-2018)

Automated downstream sync of changes from upstream as of 03-06-2018.
[no-wpt-sync]

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20911)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-06-04 09:20:57 -04:00 committed by GitHub
commit 3e8caa4679
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
278 changed files with 13348 additions and 10515 deletions

View file

@ -0,0 +1,129 @@
<!doctype html>
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
<meta name=variant content="?encoding=x-cp1251">
<meta name=variant content="?encoding=utf8">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/utils.js"></script>
<link rel=help href=https://html.spec.whatwg.org/multipage/#following-hyperlinks>
<link rel=help href=https://html.spec.whatwg.org/multipage/#hyperlink-auditing>
<link rel=help href=https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv-refresh>
<div id=log></div>
<script>
function expected(encoding) {
return {
"UTF-8": "%C3%BF",
"windows-1251": "%26%23255%3B",
"windows-1252": "%FF"
}[encoding];
}
var encoding = document.characterSet;
var blank = 'resources/blank.py?encoding=' + encoding;
var stash_put = 'resources/stash.py?q=\u00FF&action=put&id=';
var stash_take = 'resources/stash.py?action=take&id=';
var input_url_html = 'resources/resource.py?q=\u00FF&encoding=' + encoding + '&type=html';
var expected_current = expected(encoding);
var expected_utf8 = expected('UTF-8');
function assert_ends_with(input, endsWith) {
assert_true(input.endsWith(endsWith), input + " did not end with " + endsWith);
}
function poll_for_stash(test_obj, uuid, expected) {
var start = new Date();
var poll = test_obj.step_func(function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', stash_take + uuid);
xhr.onload = test_obj.step_func(function(e) {
if (xhr.response == "") {
if (new Date() - start > 10000) {
// If we set the status to TIMEOUT here we avoid a race between the
// page and the test timing out
test_obj.force_timeout();
}
test_obj.step_timeout(poll, 200);
} else {
assert_equals(xhr.response, expected);
test_obj.done();
}
});
xhr.send();
})
test_obj.step_timeout(poll, 200);
}
function setup_navigation(elm, iframe, id, test_obj) {
iframe.name = id;
elm.target = id;
elm.setAttribute('href', input_url_html);
document.body.appendChild(iframe);
document.body.appendChild(elm);
test_obj.add_cleanup(function() {
document.body.removeChild(iframe);
document.body.removeChild(elm);
});
}
// follow hyperlink
function test_follow_link(tag) {
async_test(function() {
var elm = document.createElement(tag);
var iframe = document.createElement('iframe');
setup_navigation(elm, iframe, 'test_follow_link_'+tag, this);
iframe.onload = this.step_func_done(function() { // when the page navigated to has loaded
assert_equals(iframe.contentDocument.body.textContent, expected_current);
});
// follow the hyperlink
elm.click();
// check that navigation succeeded by ...??? XXX
}, 'follow hyperlink <'+tag+' href>');
}
'a, area, link'.split(', ').forEach(function(str) {
test_follow_link(str);
});
// follow hyperlink with ping attribute
function test_follow_link_ping(tag) {
async_test(function() {
var uuid = token();
var elm = document.createElement(tag);
// check if ping is supported
assert_true('ping' in elm, 'ping not supported');
elm.setAttribute('ping', stash_put + uuid);
var iframe = document.createElement('iframe');
setup_navigation(elm, iframe, 'test_follow_link_ping_'+tag, this);
// follow the hyperlink
elm.click();
// check that navigation succeeded by ...??? XXX
// check that the right URL was requested for the ping
poll_for_stash(this, uuid, expected_current);
}, 'hyperlink auditing <'+tag+' ping>');
}
'a, area'.split(', ').forEach(function(str) {
test_follow_link_ping(str);
});
// navigating with meta refresh
async_test(function() {
var iframe = document.createElement('iframe');
iframe.src = blank;
document.body.appendChild(iframe);
this.add_cleanup(function() {
document.body.removeChild(iframe);
});
iframe.onload = this.step_func_done(function() {
var doc = iframe.contentDocument;
var got = doc.body.textContent;
if (got == '') {
doc.write('<meta http-equiv=refresh content="0; URL='+input_url_html+'">REFRESH');
doc.close();
return;
}
assert_equals(got, expected_current);
});
}, 'meta refresh');
</script>

View file

@ -26,105 +26,6 @@ onload = function() {
return 'expected substring '+expected+' got '+got;
}
function poll_for_stash(test_obj, uuid, expected) {
var start = new Date();
var poll = test_obj.step_func(function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', stash_take + uuid);
xhr.onload = test_obj.step_func(function(e) {
if (xhr.response == "") {
if (new Date() - start > 10000) {
// If we set the status to TIMEOUT here we avoid a race between the
// page and the test timing out
test_obj.force_timeout();
}
test_obj.step_timeout(poll, 200);
} else {
assert_equals(xhr.response, expected);
test_obj.done();
}
});
xhr.send();
})
test_obj.step_timeout(poll, 200);
}
function setup_navigation(elm, iframe, id, test_obj) {
iframe.name = id;
elm.target = id;
elm.setAttribute('href', input_url_html);
document.body.appendChild(iframe);
document.body.appendChild(elm);
test_obj.add_cleanup(function() {
document.body.removeChild(iframe);
document.body.removeChild(elm);
});
}
// follow hyperlink
function test_follow_link(tag) {
async_test(function() {
var elm = document.createElement(tag);
var iframe = document.createElement('iframe');
setup_navigation(elm, iframe, 'test_follow_link_'+tag, this);
iframe.onload = this.step_func_done(function() { // when the page navigated to has loaded
assert_equals(iframe.contentDocument.body.textContent, expected_current);
});
// follow the hyperlink
elm.click();
// check that navigation succeeded by ...??? XXX
}, 'follow hyperlink <'+tag+' href>',
{help:'https://html.spec.whatwg.org/multipage/#following-hyperlinks'});
}
'a, area, link'.split(', ').forEach(function(str) {
test_follow_link(str);
});
// follow hyperlink with ping attribute
function test_follow_link_ping(tag) {
async_test(function() {
var uuid = token();
var elm = document.createElement(tag);
// check if ping is supported
assert_true('ping' in elm, 'ping not supported');
elm.setAttribute('ping', stash_put + uuid);
var iframe = document.createElement('iframe');
setup_navigation(elm, iframe, 'test_follow_link_ping_'+tag, this);
// follow the hyperlink
elm.click();
// check that navigation succeeded by ...??? XXX
// check that the right URL was requested for the ping
poll_for_stash(this, uuid, expected_current);
}, 'hyperlink auditing <'+tag+' ping>',
{help:'https://html.spec.whatwg.org/multipage/#hyperlink-auditing'});
}
'a, area'.split(', ').forEach(function(str) {
test_follow_link_ping(str);
});
// navigating with meta refresh
async_test(function() {
var iframe = document.createElement('iframe');
iframe.src = blank;
document.body.appendChild(iframe);
this.add_cleanup(function() {
document.body.removeChild(iframe);
});
iframe.onload = this.step_func_done(function() {
var doc = iframe.contentDocument;
var got = doc.body.textContent;
if (got == '') {
doc.write('<meta http-equiv=refresh content="0; URL='+input_url_html+'">REFRESH');
doc.close();
return;
}
assert_equals(got, expected_current);
});
}, 'meta refresh',
{help:'https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv-refresh'});
// loading html (or actually svg to support <embed>)
function test_load_nested_browsing_context(tag, attr, spec_url) {
async_test(function() {

View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<title>UA style for hidden attribute on table elements</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#tables-2">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<table hidden></table>
<table><caption hidden></caption></table>
<table><colgroup hidden></table>
<table><col hidden></table>
<table><thead hidden></table>
<table><tbody hidden></table>
<table><tfoot hidden></table>
<table><tr hidden></table>
<table><tr><td hidden></table>
<table><tr><th hidden></table>
<script>
const expectedDisplay = {
'table': 'none',
'caption': 'none',
'colgroup': 'table-column-group',
'col': 'table-column',
'thead': 'table-header-group',
'tbody': 'table-row-group',
'tfoot': 'table-footer-group',
'tr': 'table-row',
'td': 'table-cell',
'th': 'table-cell',
};
for (const el of document.querySelectorAll("[hidden]")) {
test(function() {
const style = getComputedStyle(el);
assert_equals(style.display, expectedDisplay[el.localName]);
if (el instanceof HTMLTableElement ||
el instanceof HTMLTableCaptionElement) {
assert_equals(style.visibility, 'visible');
} else {
assert_equals(style.visibility, 'collapse');
}
}, `Computed display and visibility of ${el.localName}`);
}
</script>

View file

@ -1,3 +0,0 @@
<!doctype html>
<title> An empty test page </title>
<p> This is test page </p>

View file

@ -1,82 +0,0 @@
<!doctype html>
<html>
<head>
<title>
&lt;embed&gt;'s browsing context is discarded on 'src' attribute change.
</title>
<link rel="author" title="Ehsan Karamad" href="ekaramad@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
let url1 = "../resources/test_page.html";
let url2 = "../resources/should-load.html";
function onLoadPromise(el) {
return new Promise((resolve) => {
function onLoad() {
resolve();
el.removeEventListener("load", onLoad);
}
el.addEventListener("load", onLoad);
});
}
promise_test(async() => {
let old_windows = [];
let embed = document.createElement("embed");
embed.type = "text/html";
embed.src = url1;
let onEmbedLoad = onLoadPromise(embed);
document.body.appendChild(embed);
await onEmbedLoad;
old_windows.push(window[0]);
assert_equals(
window[0].frameElement,
embed,
"<embed> is attached and loaded with html content.");
let iframe = document.createElement("iframe");
iframe.src = url1;
let onIframeLoad = onLoadPromise(iframe);
document.body.appendChild(iframe);
await onIframeLoad;
old_windows.push(window[1]);
assert_equals(
window[1].frameElement,
iframe,
"<iframe> is attached and loaded with html content after <embed>.");
assert_equals(
window[0],
old_windows[0],
"The first window is that of <embed>'s frame.");
// Now navigate the embed element again.
onEmbedLoad = onLoadPromise(embed);
embed.src = url2;
await onEmbedLoad;
assert_equals(
window[0].frameElement,
iframe,
"<embed>'s previous frame must have been destroyed.");
assert_equals(
window[1].frameElement,
embed,
"<embed>'s new window should be appended after navigation.");
assert_not_equals(
old_windows[0],
window[1],
"The old window and new window are different for <embed>.");
assert_equals(
old_windows[1],
window[0],
"The old and new window are the same for <iframe>.");
}, "Verify that changing 'src' attribute of an <embed> element discards" +
" the old browsing context and creates a new browsing context.");
</script>
</body>
</html>

View file

@ -10,25 +10,15 @@
<body>
<iframe sandbox="allow-top-navigation allow-scripts"></iframe>
<script>
if (opener) {
// We're the popup (i.e. a top frame). Load into the iframe the page
// trying to modifying the top frame and transmit the result to our
// opener.
onmessage = function(e) {
opener.postMessage(e.data, "*")
}
document.querySelector("iframe").src = "support/iframe-that-performs-top-navigation-on-popup.html";
} else {
// We are the main test page. Open ourselves as a popup, so that we can
// can experiment navigation of the top frame.
async_test(t => {
window.addEventListener("message", t.step_func_done(e => {
assert_equals(e.data, "can navigate");
e.source.close();
}));
window.open(location.href);
}, "Frames with `allow-top-navigation` should be able to navigate the top frame.");
}
// We are the main test page. Open a popup, so that we can
// can experiment navigation of the top frame.
async_test(t => {
window.addEventListener("message", t.step_func_done(e => {
assert_equals(e.data, "can navigate");
e.source.close();
}));
window.open("support/load-into-the-iframe.html");
}, "Frames with `allow-top-navigation` should be able to navigate the top frame.");
</script>
</body>
</html>

View file

@ -8,27 +8,16 @@
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<iframe sandbox="allow-scripts"></iframe>
<script>
if (opener) {
// We're the popup (i.e. a top frame). Load into the iframe the page
// trying to modifying the top frame and transmit the result to our
// opener.
onmessage = function(e) {
opener.postMessage(e.data, "*")
}
document.querySelector("iframe").src = "support/iframe-that-performs-top-navigation-on-popup.html";
} else {
// We are the main test page. Open ourselves as a popup, so that we can
// can experiment navigation of the top frame.
async_test(t => {
window.addEventListener("message", t.step_func_done(e => {
assert_equals(e.data, "cannot navigate");
e.source.close();
}));
window.open(location.href);
}, "Frames without `allow-top-navigation` should not be able to navigate the top frame.");
}
// We are the main test page. Open a popup, so that we can
// can experiment navigation of the top frame.
async_test(t => {
window.addEventListener("message", t.step_func_done(e => {
assert_equals(e.data, "cannot navigate");
e.source.close();
}));
window.open('support/load-into-the-iframe.html');
}, "Frames without `allow-top-navigation` should not be able to navigate the top frame.");
</script>
</body>
</html>

View file

@ -14,25 +14,15 @@
error: allow-top-navigation-by-user-activation will have no effect. -->
<iframe sandbox="allow-top-navigation allow-top-navigation-by-user-activation allow-scripts"></iframe>
<script>
if (opener) {
// We're the popup (i.e. a top frame). Load into the iframe the page
// trying to modifying the top frame and transmit the result to our
// opener.
onmessage = function(e) {
opener.postMessage(e.data, "*")
}
document.querySelector("iframe").src = "support/iframe-that-performs-top-navigation-on-popup.html";
} else {
// We are the main test page. Open ourselves as a popup, so that we can
// can experiment navigation of the top frame.
async_test(t => {
window.addEventListener("message", t.step_func_done(e => {
assert_equals(e.data, "can navigate");
e.source.close();
}));
window.open(location.href);
}, "Frames with `allow-top-navigation` should be able to navigate the top frame even when `allow-top-navigation-by-user-activation` is set.");
}
// We are the main test page. Open a popup, so that we can
// can experiment navigation of the top frame.
async_test(t => {
window.addEventListener("message", t.step_func_done(e => {
assert_equals(e.data, "can navigate");
e.source.close();
}));
window.open("support/load-into-the-iframe.html");
}, "Frames with `allow-top-navigation` should be able to navigate the top frame even when `allow-top-navigation-by-user-activation` is set.");
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe sandbox="allow-scripts"></iframe>
<script>
// We're the popup (i.e. a top frame). Load into the iframe the page
// trying to modifying the top frame and transmit the result to our
// opener.
onmessage = function(e) {
opener.postMessage(e.data, "*")
}
document.querySelector("iframe").src = "iframe-that-performs-top-navigation-on-popup.html";
</script>
</body>
</html>

View file

@ -1,83 +0,0 @@
<!doctype html>
<html>
<head>
<title>
&lt;object&gt;'s browsing context is discarded on 'data' attribute change.
</title>
<link rel="author" title="Ehsan Karamad" href="ekaramad@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
let url1 = "../resources/test_page.html";
let url2 = "../resources/should-load.html";
function onLoadPromise(el) {
return new Promise((resolve) => {
function onLoad() {
resolve();
el.removeEventListener("load", onLoad);
}
el.addEventListener("load", onLoad);
});
}
promise_test(async() => {
let old_windows = [];
let object = document.createElement("object");
object.type = "text/html";
object.data = url1;
let onObjectLoad = onLoadPromise(object);
document.body.appendChild(object);
await onObjectLoad;
old_windows.push(window[0]);
assert_equals(
window[0].frameElement,
object,
"<object> is attached and loaded with html content.");
let iframe = document.createElement("iframe");
iframe.src = url1;
let onIframeLoad = onLoadPromise(iframe);
document.body.appendChild(iframe);
await onIframeLoad;
old_windows.push(window[1]);
assert_equals(
window[1].frameElement,
iframe,
"<iframe> is attached and loaded with html content after <object>.");
assert_equals(
window[0],
old_windows[0],
"The first window is that of <object>'s frame.");
// Now navigate the object element again.
onObjectLoad = onLoadPromise(object);
object.data = url2;
await onObjectLoad;
assert_equals(
window[0].frameElement,
iframe,
"<object>'s previous frame must have been destroyed.");
assert_equals(
window[1].frameElement,
object,
"<object>'s new window should be appended after navigation.");
assert_not_equals(
old_windows[0],
window[1],
"The old window and new window are different for <object>.");
assert_equals(
old_windows[1],
window[0],
"The old and new window are the same for <iframe>.");
}, "Verify that changing 'data' attribute of an <object> element discards" +
" the old browsing context and creates a new browsing context.");
</script>
</body>
</html>

View file

@ -96,6 +96,7 @@ promise_test(t => {
"onclick",
`import('../imports-a.js?label=inline event handlers triggered via UA code').then(window.continueTest, window.errorTest)`
);
assert_equals(typeof dummyDiv.onclick, "function", "the browser must be able to parse a string containing the import() syntax into a function");
dummyDiv.click(); // different from **on**click()
return promise.then(assertSuccessful);

View file

@ -95,6 +95,7 @@ promise_test(t => {
"onclick",
`import('../imports-a.js?label=inline event handlers triggered via UA code').then(window.continueTest, window.errorTest)`
);
assert_equals(typeof dummyDiv.onclick, 'function', "the browser must be able to parse a string containing the import() syntax into a function");
dummyDiv.click(); // different from **on**click()
return promise.then(assertSuccessful);