Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it trivial to have a test run in window and worker scopes #2558

Closed
Ms2ger opened this issue Feb 3, 2016 · 5 comments
Closed

Make it trivial to have a test run in window and worker scopes #2558

Ms2ger opened this issue Feb 3, 2016 · 5 comments

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented Feb 3, 2016

Right now, the most straightforward way requires three files:

function test_withCredentials(worker) {
  test(function() {
    ...
  })
<!doctype html>
<meta charset=utf-8>
<title>XMLHttpRequest#withCredentials</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=XMLHttpRequest-withCredentials.js></script>
<div id="log"></div>
<script>
test_withCredentials(false)
</script>
importScripts("/resources/testharness.js")
importScripts("XMLHttpRequest-withCredentials.js")
test_withCredentials(true);
done()

Since the latter two files are entirely boilerplate, we should be able to do it with just one file.

@domenic
Copy link
Member

domenic commented Feb 4, 2016

Streams and unhandled promise rejections (#2388) really wants this too. We are using the following pattern:

<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-workers/resources/test-helpers.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/#unhandled-promise-rejections">

<script src="support/test-helper-1.js"></script>
<script src="support/test-helper-2.js"></script>
<script src="support/promise-rejection-events.js"></script>
<script>
fetch_tests_from_worker(new Worker('support/promise-rejection-events.js'));
fetch_tests_from_worker(new SharedWorker('support/promise-rejection-events.js'));
service_worker_test('support/promise-rejection-events.js');
</script>
// support/promise-rejection-events.js
'use strict';

if (self.importScripts) {
  importScripts('/resources/testharness.js');
  importScripts('/resources/test-helper-1.js');
  importScripts('/resources/test-helper-2.js');
}

// Tests go here...

done();

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Feb 26, 2016

bz suggested testname.chameleon.js, testname.allscopes.js, testname.allglobals.js, testname.everywhere.js, testname.testmeharder.js.

Ms2ger added a commit to w3c/wpt-tools that referenced this issue Jul 23, 2016
jgraham pushed a commit to w3c/wpt-tools that referenced this issue Jul 26, 2016
* Implement support for multi-global tests.

CC <web-platform-tests/wpt#2558>.

* Make the .any.js and .worker.js handlers more robust against unexpected file names.
@annevk
Copy link
Member

annevk commented Mar 14, 2017

@Ms2ger w3c/wpt-tools#88 fixed this right in the form of .any.js?

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Mar 14, 2017

Yep, thanks

@Ms2ger Ms2ger closed this as completed Mar 14, 2017
@domenic
Copy link
Member

domenic commented Mar 14, 2017

Note, however, #4210 is still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants