Update web-platform-tests to revision b382ac7192087da0a7439902e20be76ab7587ee8

This commit is contained in:
WPT Sync Bot 2018-08-10 21:31:07 -04:00
parent 3e96a322ae
commit defee2aae0
45 changed files with 645 additions and 189 deletions

View file

@ -14,14 +14,14 @@ async function getMessageFromServiceWorker() {
});
}
// Registers the instrumentation Service Worker located at "resources/sw.js"
// Registers the |name| instrumentation Service Worker located at "service_workers/"
// with a scope unique to the test page that's running, and waits for it to be
// activated. The Service Worker will be unregistered automatically.
//
// Depends on /service-workers/service-worker/resources/test-helpers.sub.js
async function registerAndActivateServiceWorker(test) {
const script = 'resources/sw.js';
const scope = 'resources/scope' + location.pathname;
async function registerAndActivateServiceWorker(test, name) {
const script = `service_workers/${name}`;
const scope = 'service_workers/scope' + location.pathname;
let serviceWorkerRegistration =
await service_worker_unregister_and_register(test, script, scope);
@ -35,10 +35,13 @@ async function registerAndActivateServiceWorker(test) {
// Creates a Promise test for |func| given the |description|. The |func| will be
// executed with the `backgroundFetch` object of an activated Service Worker
// Registration.
function backgroundFetchTest(func, description) {
// |workerName| is the name of the service worker file in the service_workers
// directory to register.
function backgroundFetchTest(func, description, workerName = 'sw.js') {
promise_test(async t => {
const serviceWorkerRegistration = await registerAndActivateServiceWorker(t);
serviceWorkerRegistration.active.postMessage(null /* unused */);
const serviceWorkerRegistration =
await registerAndActivateServiceWorker(t, workerName);
serviceWorkerRegistration.active.postMessage(null);
assert_equals(await getMessageFromServiceWorker(), 'ready');

View file

@ -0,0 +1,12 @@
// The source to post setup and completion results to.
let source = null;
function sendMessageToDocument(msg) {
source.postMessage(msg);
}
// Notify the document that the SW is registered and ready.
self.addEventListener('message', event => {
source = event.source;
sendMessageToDocument('ready');
});

View file

@ -0,0 +1,22 @@
importScripts('sw-helpers.js');
async function updateUI(event) {
let updateParams = [];
switch (event.id) {
case 'update-once':
updateParams = [{title: 'Title1'}];
break;
case 'update-twice':
updateParams = [{title: 'Title1'}, {title: 'Title2'}];
break;
}
return Promise.all(updateParams.map(param => event.updateUI(param)))
.then(() => 'update success')
.catch(e => e.message);
}
self.addEventListener('backgroundfetched', event => {
event.waitUntil(updateUI(event)
.then(update => sendMessageToDocument({ type: event.type, update })))
});

View file

@ -1,4 +1,4 @@
let source = null;
importScripts('sw-helpers.js');
async function getFetchResult(settledFetch) {
if (!settledFetch.response)
@ -11,14 +11,9 @@ async function getFetchResult(settledFetch) {
};
}
self.addEventListener('message', event => {
source = event.source;
source.postMessage('ready');
});
self.addEventListener('backgroundfetched', event => {
event.waitUntil(
event.fetches.values()
.then(fetches => Promise.all(fetches.map(fetch => getFetchResult(fetch))))
.then(results => source.postMessage({ type: event.type, results })));
.then(results => sendMessageToDocument({ type: event.type, results })));
});

View file

@ -0,0 +1,32 @@
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
// META: script=resources/utils.js
'use strict';
// Covers functionality provided by BackgroundFetchUpdateEvent.updateUI().
//
// https://wicg.github.io/background-fetch/#backgroundfetchupdateuievent
const swName = 'sw-update-ui.js';
backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = 'update-once';
const registration =
await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
assert_equals(registration.id, registrationId);
const message = await getMessageFromServiceWorker();
assert_equals(message.update, 'update success');
}, 'Background Fetch updateUI resolves', swName);
backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = 'update-twice';
const registration =
await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
assert_equals(registration.id, registrationId);
const message = await getMessageFromServiceWorker();
assert_equals(message.update, 'updateUI may only be called once.');
}, 'Background Fetch updateUI called twice fails', swName);

View file

@ -0,0 +1,24 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
'use strict';
// See https://wicg.github.io/budget-api/
idl_test(
['budget-api'],
['html'],
async idl_array => {
idl_array.add_objects({ BudgetService: ['navigator.budget'] });
if (self.Window) {
idl_array.add_objects({ Navigator: ['navigator'] });
} else {
idl_array.add_objects({ WorkerNavigator: ['navigator'] });
}
const budgetStates = await navigator.budget.getBudget();
if (budgetStates.length) {
self.budgetState = budgetStates[0];
idl_array.add_objects({ BudgetState: ['budgetState'] });
}
}
);

View file

@ -1,19 +0,0 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
'use strict';
// See https://wicg.github.io/budget-api/
promise_test(async () => {
const html = await fetch('/interfaces/html.idl').then(r => r.text());
const workers = await fetch('/interfaces/dedicated-workers.idl').then(r => r.text());
const idl = await fetch('/interfaces/budget-api.idl').then(r => r.text());
const idlArray = new IdlArray();
idlArray.add_idls(idl);
idlArray.add_dependency_idls(html);
idlArray.add_dependency_idls(workers);
idlArray.test();
done();
}, 'budget-api interfaces.');

View file

@ -0,0 +1,70 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>reference for abspos-inline-007</title>
<style type="text/css">
.block-container {
font: 20px Ahem;
height: 20px;
position: relative;
top: -1px;
}
.inline-container {
position: relative;
border: 1px solid black;
display: inline-block;
}
.parent-block {
display: inline-block;
width: 30px;
height: 10px;
}
.abspos {
position: absolute;
width: 10px;
height: 10px;
background-color: green;
display: inline-block;
vertical-align: baseline;
}
.br {
right: 0;
bottom: 0;
}
.tl {
top: 0;
left: 0;
}
.filler {
display: inline-block;
width: 30px;
height: 10px;
}
</style>
</head>
<body>
<div class="block-container">
x
<div class="inline-container">
tl
<div class="abspos tl"></div>
<div class="parent-block"></div>
<div class="filler"></div>&nbsp;
</div>x
<div class="inline-container">
br
<div class="abspos br"></div>
<div class="parent-block"></div>
<div class="filler"></div>&nbsp;
</div>x
<div class="inline-container">
static
<div class="abspos" style="position:static"></div><div class="parent-block"></div>
<div class="filler" style="width: 20px;"></div>
</div>
</div>
<p>Tests abspos positioning of an Element that 1) has an inline containing
block, and 2) is not a child of the inline containing block, but a descendant.</p>
</body>
</html>

View file

@ -0,0 +1,74 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Test: Absolutely positioned descendants in inlines</title>
<link rel="author" title="Aleks Totic" href="mailto:atotic@chromium.org"/>
<link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#comp-abspos" />
<link rel="match" href="abspos-inline-007-ref.xht" />
<style type="text/css">
.block-container {
position: relative;
font: 20px Ahem;
}
.inline-container {
position: relative;
border: 1px solid black;
}
.parent-block {
display: inline-block;
width: 30px;
height: 10px;
}
.abspos {
position: absolute;
width: 10px;
height: 10px;
background-color: green;
}
.br {
right: 0;
bottom: 0;
}
.tl {
top: 0;
left: 0;
}
.filler {
display: inline-block;
width: 30px;
height: 10px;
}
</style>
</head>
<body>
<div class="block-container">
x
<span class="inline-container">
tl
<div class="parent-block">
<div class="abspos tl"></div>
</div>
<div class="filler"></div>
</span>
x
<span class="inline-container">
br
<div class="parent-block">
<div class="abspos br"></div>
</div>
<div class="filler"></div>
</span>
x
<span class="inline-container">
static
<div class="parent-block">
<div class="abspos"></div>
</div>
<div class="filler"></div>
</span>
</div>
<p>Tests abspos positioning of an Element that 1) has an inline containing
block, and 2) is not a child of the inline containing block, but a descendant.</p>
</body>
</html>

View file

@ -10,11 +10,11 @@
== attachment-local-clipping-color-3.html attachment-local-clipping-color-3-ref.html
== attachment-local-clipping-color-4.html attachment-local-clipping-color-4-ref.html
== attachment-local-clipping-color-5.html attachment-local-clipping-color-4-ref.html # Same ref as the previous test.
fuzzy(50,500) == attachment-local-clipping-color-6.html attachment-local-clipping-color-6-ref.html
fuzzy(0-50,0-500) == attachment-local-clipping-color-6.html attachment-local-clipping-color-6-ref.html
== attachment-local-clipping-image-1.html attachment-local-clipping-image-1-ref.html
== attachment-local-clipping-image-2.html attachment-local-clipping-image-1-ref.html # Same ref as the previous test.
== attachment-local-clipping-image-3.html attachment-local-clipping-image-3-ref.html
== attachment-local-clipping-image-4.html attachment-local-clipping-image-4-ref.html
== attachment-local-clipping-image-5.html attachment-local-clipping-image-4-ref.html # Same ref as the previous test.
fuzzy(80,500) == attachment-local-clipping-image-6.html attachment-local-clipping-image-6-ref.html
fuzzy(0-80,0-500) == attachment-local-clipping-image-6.html attachment-local-clipping-image-6-ref.html

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>vertical-rl, relatively positioned inline in block that overflows smaller parent</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#vertical-layout" title="7.1. Principles of Layout in Vertical Writing Modes">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht" />
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="position:relative; writing-mode:vertical-rl; width:100px; height:100px; background:green;">
<div style="position:absolute; right:0; top:0; width:0.5em; height:1em; background:red;"></div>
<div style="width:200px;">
<span style="position:relative; color:green; background:green;">XXX</span>
</div>
</div>

View file

@ -0,0 +1,13 @@
// META: global=window,dedicatedworker,sharedworker,serviceworker
test(t => {
// Test for object that's only exposed in serviceworker
if (self.clients) {
assert_true(self.isSecureContext);
assert_equals(location.protocol, "https:");
} else {
assert_false(self.isSecureContext);
assert_equals(location.protocol, "http:");
}
});
done();

View file

@ -1,3 +1,4 @@
// META: global=window,dedicatedworker,sharedworker,serviceworker
test(() => {
assert_true(self.isSecureContext);
}, "Use of .https file name flag implies secure context");

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<div style="background: green">
<div>Expected: a black square on green background.</div>
<svg style="height: 200px">
<foreignObject>
<div style="width: 200px; height: 200px; background: black"></div>
</foreignObject>
</svg>
</div>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>'mix-blend-mode' for &lt;svg:foreignObject&gt;</title>
<link rel="help" href="https://www.w3.org/TR/SVG2/render.html#PaintersModel">
<link rel="match" href="blending-svg-foreign-object-ref.html">
<div style="background: green">
<div>Expected: a black square on green background.</div>
<svg style="width: 200px; height: 200px">
<foreignObject style="mix-blend-mode: multiply">
<div style="width: 200px; height: 200px; background: red"></div>
</foreignObject>
</svg>
</div>

View file

@ -0,0 +1,6 @@
<!DOCTYPE html>
<div style="background: green">
<div>Expected: a black square on green background.</div>
<svg style="width: 200px; height: 200px; background: black">
</svg>
</div>

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<title>'mix-blend-mode' for &lt;svg&gt;</title>
<link rel="help" href="https://www.w3.org/TR/SVG2/render.html#PaintersModel">
<link rel="match" href="blending-svg-root-ref.html">
<div style="background: green">
<div>Expected: a black square on green background.</div>
<svg style="mix-blend-mode: multiply; width: 200px; height: 200px; background: red">
</svg>
</div>

View file

@ -1,4 +1,4 @@
from six.moves.urllib.parse import urljoin
from six.moves.urllib.parse import urljoin, urlparse
from abc import ABCMeta, abstractproperty
@ -46,6 +46,10 @@ class ManifestItem(object):
"""The test's id (usually its url)"""
pass
@property
def meta_flags(self):
return set(self.source_file.meta_flags)
@property
def path(self):
"""The test path relative to the test_root"""
@ -53,7 +57,8 @@ class ManifestItem(object):
@property
def https(self):
return "https" in self.source_file.meta_flags
flags = self.meta_flags
return ("https" in flags or "serviceworker" in flags)
def key(self):
"""A unique identifier for the test"""
@ -95,6 +100,10 @@ class URLManifestItem(ManifestItem):
def id(self):
return self.url
@property
def meta_flags(self):
return set(urlparse(self.url).path.rsplit("/", 1)[1].split(".")[1:-1])
@property
def url(self):
return urljoin(self.url_base, self._url)

View file

@ -113,8 +113,6 @@ def global_suffixes(value):
for global_type in global_types:
variant = _any_variants[global_type]
suffix = variant.get("suffix", ".any.%s.html" % global_type.decode("utf-8"))
if variant.get("force_https", False):
suffix = ".https" + suffix
rv.add((suffix, global_type == b"jsshell"))
return rv
@ -623,7 +621,8 @@ class SourceFile(object):
break
tests = [
TestharnessTest(self, global_variant_url(self.url, suffix) + variant, timeout=self.timeout, jsshell=jsshell)
TestharnessTest(self, global_variant_url(self.url, suffix) + variant, timeout=self.timeout,
jsshell=jsshell)
for (suffix, jsshell) in sorted(global_suffixes(globals))
for variant in self.test_variants
]

View file

@ -0,0 +1,23 @@
from ..item import SupportFile, URLManifestItem
from ..sourcefile import SourceFile
def test_base_meta_flags():
s = SourceFile("/", "a.b.c.d", "/", contents="")
m = SupportFile(s)
assert m.meta_flags == {"b", "c"}
def test_url_meta_flags():
s = SourceFile("/", "a.b.c", "/", contents="")
m = URLManifestItem(s, "/foo.bar/a.b.d.e")
assert m.meta_flags == {"b", "d"}
def test_url_empty_meta_flags():
s = SourceFile("/", "a.b.c", "/", contents="")
m = URLManifestItem(s, "/foo.bar/abcde")
assert m.meta_flags == set()

View file

@ -366,7 +366,7 @@ test()""" % input
urls = {
"dedicatedworker": "/html/test.any.worker.html",
"serviceworker": "/html/test.https.any.serviceworker.html",
"serviceworker": "/html/test.any.serviceworker.html",
"sharedworker": "/html/test.any.sharedworker.html",
"window": "/html/test.any.html",
}
@ -431,7 +431,7 @@ test()"""
urls = {
"dedicatedworker": "/html/test.any.worker.html",
"serviceworker": "/html/test.https.any.serviceworker.html",
"serviceworker": "/html/test.any.serviceworker.html",
"sharedworker": "/html/test.any.sharedworker.html",
"window": "/html/test.any.html",
}

View file

@ -249,7 +249,7 @@ fetch_tests_from_worker(new SharedWorker("%(path)s%(query)s"));
class ServiceWorkersHandler(HtmlWrapperHandler):
global_type = b"serviceworker"
path_replace = [(".https.any.serviceworker.html", ".any.js", ".any.worker.js")]
path_replace = [(".any.serviceworker.html", ".any.js", ".any.worker.js")]
wrapper = """<!doctype html>
<meta charset=utf-8>
%(meta)s
@ -342,7 +342,7 @@ class RoutesBuilder(object):
("GET", "*.window.html", WindowHandler),
("GET", "*.any.html", AnyHtmlHandler),
("GET", "*.any.sharedworker.html", SharedWorkersHandler),
("GET", "*.https.any.serviceworker.html", ServiceWorkersHandler),
("GET", "*.any.serviceworker.html", ServiceWorkersHandler),
("GET", "*.any.worker.js", AnyWorkerHandler),
("GET", "*.asis", handlers.AsIsHandler),
("*", "*.py", handlers.PythonScriptHandler),