Skip to content

Commit

Permalink
Update web-platform-tests to revision a8fb1792cbfab3ed59401775da76fb6…
Browse files Browse the repository at this point in the history
…c15d9f2e2
  • Loading branch information
servo-wpt-sync authored and Tom Servo committed Nov 23, 2018
1 parent 1bac32e commit 642f3cb
Show file tree
Hide file tree
Showing 2,857 changed files with 299,597 additions and 289,556 deletions.
512,050 changes: 256,975 additions & 255,075 deletions tests/wpt/metadata/MANIFEST.json

Large diffs are not rendered by default.

24,788 changes: 12,394 additions & 12,394 deletions tests/wpt/mozilla/meta/MANIFEST.json

Large diffs are not rendered by default.

134 changes: 71 additions & 63 deletions tests/wpt/web-platform-tests/.azure-pipelines.yml
@@ -1,7 +1,10 @@
# This is the configuration file for Azure Pipelines, used to run tests on
# macOS. Documentation to help understand this setup:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/multiple-phases
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/index
#
# In addition to this configuration file, the "Build pull requests from forks
# of this repository" setting must also be enabled in the Azure DevOps project:
Expand All @@ -10,76 +13,81 @@
trigger: none # disable builds for branches

jobs:
- job: macOS

- job: root
displayName: './wpt test-jobs'
pool:
vmImage: 'macOS-10.13'

vmImage: 'ubuntu-16.04'
steps:
- checkout: self
fetchDepth: 50
submodules: false

- template: tools/ci/azure/checkout.yml
- script: |
echo "Test jobs:"
./wpt test-jobs | while read job; do
echo "$job"
echo "##vso[task.setvariable variable=run_$job]true";
echo "##vso[task.setvariable variable=$job;isOutput=true]true";
done
displayName: 'List test jobs'
- script: |
sudo easy_install pip
sudo pip install -U virtualenv
displayName: 'Install Python packages'
condition: variables.run_wptrunner_infrastructure
# Installig Ahem in /Library/Fonts instead of using --install-fonts is a
# workaround for https://github.com/web-platform-tests/wpt/issues/13803.
- script: sudo cp fonts/Ahem.ttf /Library/Fonts
displayName: 'Install Ahem font'
condition: variables.run_wptrunner_infrastructure

- script: |
# https://github.com/web-platform-tests/results-collection/blob/master/src/scripts/trust-root-ca.sh
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain tools/certs/cacert.pem
displayName: 'Install web-platform.test certificate'
condition: variables.run_wptrunner_infrastructure
- script: HOMEBREW_NO_AUTO_UPDATE=1 brew cask install Homebrew/homebrew-cask-versions/google-chrome-dev
displayName: 'Install Chrome Dev'
condition: variables.run_wptrunner_infrastructure

- script: HOMEBREW_NO_AUTO_UPDATE=1 brew cask install Homebrew/homebrew-cask-versions/firefox-nightly
displayName: 'Install Firefox Nightly'
condition: variables.run_wptrunner_infrastructure

- script: |
# Pin to STP 67, as SafariDriver isn't working in 68:
# https://github.com/web-platform-tests/wpt/issues/13800
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install https://raw.githubusercontent.com/Homebrew/homebrew-cask-versions/23fae0a88868911913c2ee7d527c89164b6d5720/Casks/safari-technology-preview.rb
# https://web-platform-tests.org/running-tests/safari.html
sudo "/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver" --enable
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically 1
displayName: 'Install Safari Technology Preview'
condition: variables.run_wptrunner_infrastructure
- script: ./wpt make-hosts-file | sudo tee -a /etc/hosts
displayName: 'Update /etc/hosts'
condition: variables.run_wptrunner_infrastructure

- script: ./wpt manifest
displayName: 'Update manifest'
condition: variables.run_wptrunner_infrastructure
name: test_jobs
displayName: 'Run ./wpt test-jobs'
- job: infrastructure_macOS
displayName: 'infrastructure/ tests (macOS)'
dependsOn: root
condition: dependencies.root.outputs['test_jobs.wptrunner_infrastructure']
pool:
vmImage: 'macOS-10.13'
steps:
- template: tools/ci/azure/checkout.yml
- template: tools/ci/azure/pip_install.yml
parameters:
packages: virtualenv
- template: tools/ci/azure/install_fonts.yml
- template: tools/ci/azure/install_certs.yml
- template: tools/ci/azure/install_chrome.yml
- template: tools/ci/azure/install_firefox.yml
- template: tools/ci/azure/install_safari.yml
- template: tools/ci/azure/update_hosts.yml
- template: tools/ci/azure/update_manifest.yml
- script: no_proxy='*' ./wpt run --yes --no-manifest-update --manifest MANIFEST.json --metadata infrastructure/metadata/ --channel=dev chrome infrastructure/
displayName: 'Run infrastructure/ tests (Chrome Dev)'
condition: variables.run_wptrunner_infrastructure

displayName: 'Run tests (Chrome Dev)'
- script: no_proxy='*' ./wpt run --yes --no-manifest-update --manifest MANIFEST.json --metadata infrastructure/metadata/ --channel=nightly firefox infrastructure/
displayName: 'Run infrastructure/ tests (Firefox Nightly)'
condition: variables.run_wptrunner_infrastructure

displayName: 'Run tests (Firefox Nightly)'
- script: no_proxy='*' ./wpt run --yes --no-manifest-update --manifest MANIFEST.json --metadata infrastructure/metadata/ --channel=preview safari_webdriver infrastructure/
displayName: 'Run infrastructure/ tests (Safari Technology Preview)'
condition: variables.run_wptrunner_infrastructure
displayName: 'Run tests (Safari Technology Preview)'

- job: tools_unittest_macOS
displayName: 'tools/ unittests (macOS)'
dependsOn: root
condition: dependencies.root.outputs['test_jobs.tools_unittest']
pool:
vmImage: 'macOS-10.13'
steps:
- template: tools/ci/azure/checkout.yml
- template: tools/ci/azure/tox_pytest.yml
parameters:
directory: tools/
toxenv: py27

- job: wptrunner_unittest_macOS
displayName: 'tools/wptrunner/ unittests (macOS)'
dependsOn: root
condition: dependencies.root.outputs['test_jobs.wptrunner_unittest']
pool:
vmImage: 'macOS-10.13'
steps:
- template: tools/ci/azure/checkout.yml
- template: tools/ci/azure/tox_pytest.yml
parameters:
directory: tools/wptrunner/

- job: wpt_integration_macOS
displayName: 'tools/wpt/ tests (macOS)'
dependsOn: root
condition: dependencies.root.outputs['test_jobs.wpt_integration']
pool:
vmImage: 'macOS-10.13'
steps:
# full checkout required
- template: tools/ci/azure/install_chrome.yml
- template: tools/ci/azure/install_firefox.yml
- template: tools/ci/azure/update_hosts.yml
- template: tools/ci/azure/tox_pytest.yml
parameters:
directory: tools/wpt/
10 changes: 3 additions & 7 deletions tests/wpt/web-platform-tests/.gitignore
Expand Up @@ -5,19 +5,15 @@ _venv/
.cache/
.pytest_cache/
.tox/
.coverage*

# Node
node_modules/

# WPT repo stuff
/MANIFEST.json

testharness_runner.html
!/testharness_runner.html
!/tools/wptrunner/wptrunner/testharness_runner.html

_certs
config.json
.wptcache/
/config.json

# Various OS/editor specific files
*#
Expand Down
@@ -0,0 +1,6 @@
{
"feature-policy": [
"camera 'self' https://example.org",
"geolocation https://example.org/"
]
}
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>IDBFactory.databases() and opaque origins</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

function load_iframe(src, sandbox) {
return new Promise(resolve => {
const iframe = document.createElement('iframe');
iframe.onload = () => { resolve(iframe); };
if (sandbox)
iframe.sandbox = sandbox;
iframe.srcdoc = src;
iframe.style.display = 'none';
document.documentElement.appendChild(iframe);
});
}

function wait_for_message(iframe) {
return new Promise(resolve => {
self.addEventListener('message', function listener(e) {
if (e.source === iframe.contentWindow) {
resolve(e.data);
self.removeEventListener('message', listener);
}
});
});
}

const script =
'<script>' +
' window.onmessage = () => {' +
' indexedDB.databases().then(' +
' () => window.parent.postMessage({result: "no exception"}, "*"),' +
' ex => window.parent.postMessage({result: ex.name}, "*"));' +
' };' +
'<\/script>';

promise_test(async t => {
const iframe = await load_iframe(script);
iframe.contentWindow.postMessage({}, '*');
const message = await wait_for_message(iframe);
assert_equals(message.result, 'no exception',
'IDBFactory.databases() should not reject');
}, 'IDBFactory.databases() in non-sandboxed iframe should not reject');

promise_test(async t => {
const iframe = await load_iframe(script, 'allow-scripts');
iframe.contentWindow.postMessage({}, '*');
const message = await wait_for_message(iframe);
assert_equals(message.result, 'SecurityError',
'Exception should be SecurityError');
}, 'IDBFactory.databases() in sandboxed iframe should reject');
</script>
Expand Up @@ -8,7 +8,7 @@
backgroundFetchTest(async (test, backgroundFetch) => {
const registration = await backgroundFetch.fetch(
uniqueId(),
['resources/feature-name.txt', '/serviceworker/resources/slow-response.php']);
['resources/feature-name.txt', '/common/slow.py']);

assert_true(await registration.abort());
assert_false(await registration.abort());
Expand All @@ -18,7 +18,7 @@ backgroundFetchTest(async (test, backgroundFetch) => {
backgroundFetchTest(async (test, backgroundFetch) => {
const registration = await backgroundFetch.fetch(
uniqueId(),
['resources/feature-name.txt', '/serviceworker/resources/slow-response.php']);
['resources/feature-name.txt', '/common/slow.py']);

await new Promise(resolve => {
let aborted = false;
Expand Down Expand Up @@ -63,7 +63,7 @@ backgroundFetchTest(async (test, backgroundFetch) => {

backgroundFetchTest(async (test, backgroundFetch) => {
const registration = await backgroundFetch.fetch(
uniqueId(), '/serviceworker/resources/slow-response.php');
uniqueId(), '/common/slow.py');
assert_true(await registration.abort());

const {results} = await getMessageFromServiceWorker();
Expand Down
@@ -0,0 +1,23 @@
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
// META: script=resources/utils.js
'use strict';

// Covers basic functionality provided by BackgroundFetchManager.fetch().
// Specifically, when `fetch` contains request uploads.
// https://wicg.github.io/background-fetch/#background-fetch-manager-fetch

backgroundFetchTest(async (test, backgroundFetch) => {
const uploadData = 'Background Fetch!';
const request =
new Request('resources/upload.py', {method: 'POST', body: uploadData});

await backgroundFetch.fetch(uniqueId(), request);
const {type, eventRegistration, results} = await getMessageFromServiceWorker();

assert_equals(type, 'backgroundfetchsuccess');
assert_equals(results.length, 1);
assert_equals(eventRegistration.result, 'success');
assert_equals(eventRegistration.failureReason, '');
assert_equals(results[0].text, uploadData);

}, 'Fetch with an upload should work');
48 changes: 26 additions & 22 deletions tests/wpt/web-platform-tests/background-fetch/fetch.https.window.js
Expand Up @@ -195,27 +195,6 @@ backgroundFetchTest(async (test, backgroundFetch) => {

}, 'Fetches can have requests with duplicate URLs');

backgroundFetchTest(async (test, backgroundFetch) => {
const request =
new Request('resources/feature-name.txt',
{method: 'POST', body: 'TestBody'});

const registration = await backgroundFetch.fetch('my-id', request);

const {type, eventRegistration, results} = await getMessageFromServiceWorker();
assert_equals('backgroundfetchsuccess', type);
assert_equals(results.length, 1);

assert_equals(eventRegistration.id, registration.id);
assert_equals(eventRegistration.failureReason, '');

assert_true(results[0].url.includes('resources/feature-name.txt'));
assert_equals(results[0].status, 200);
assert_equals(results[0].text, 'Background Fetch');


}, 'Fetches can have requests with a body');

backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = uniqueId();
const registration =
Expand Down Expand Up @@ -319,4 +298,29 @@ backgroundFetchTest(async (test, backgroundFetch) => {
assert_equals(eventRegistration.result, 'success');
assert_equals(eventRegistration.failureReason, '');

}, 'Matching to a non-existing request should work');
}, 'Matching to a non-existing request should work');

backgroundFetchTest(async (test, backgroundFetch) => {
const registrationId = 'matchexistingrequesttwice';
const registration =
await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');

assert_equals(registration.id, registrationId);

const {type, eventRegistration, results} = await getMessageFromServiceWorker();
assert_equals('backgroundfetchsuccess', type);
assert_equals(results.length, 2);

assert_equals(eventRegistration.id, registration.id);
assert_equals(eventRegistration.result, 'success');
assert_equals(eventRegistration.failureReason, '');

assert_true(results[0].url.includes('resources/feature-name.txt'));
assert_equals(results[0].status, 200);
assert_equals(results[0].text, 'Background Fetch');

assert_true(results[1].url.includes('resources/feature-name.txt'));
assert_equals(results[1].status, 200);
assert_equals(results[1].text, 'error');

}, 'Matching multiple times on the same request works as expected.');
@@ -0,0 +1,3 @@
# Simply returns the request body to check if the upload succeeded.
def main(request, response):
return 200, [("Content-Type", request.headers['content-type'])], request.body
Expand Up @@ -8,17 +8,25 @@ async function getFetchResult(record) {
return {
url: response.url,
status: response.status,
text: await response.text(),
text: await response.text().catch(() => 'error'),
};
}

function handleBackgroundFetchEvent(event) {
let matchFunction = null;

switch (event.registration.id) {
case 'matchexistingrequest':
matchFunction = event.registration.match.bind(
event.registration, '/background-fetch/resources/feature-name.txt');
break;
case 'matchexistingrequesttwice':
matchFunction = (async () => {
const match1 = await event.registration.match('/background-fetch/resources/feature-name.txt');
const match2 = await event.registration.match('/background-fetch/resources/feature-name.txt');
return [match1, match2];
}).bind(event.registration);
break;
case 'matchmissingrequest':
matchFunction = event.registration.match.bind(
event.registration, '/background-fetch/resources/missing.txt');
Expand All @@ -38,7 +46,7 @@ function handleBackgroundFetchEvent(event) {
})
// Extract responses.
.then(records =>
Promise.all(records.map(record => getFetchResult(record))))
Promise.all(records.map(record => getFetchResult(record))))
// Clone registration and send message.
.then(results => {
const registrationCopy = cloneRegistration(event.registration);
Expand Down

0 comments on commit 642f3cb

Please sign in to comment.