-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1658822 [wpt PR 24983] - Update and expand worker MIME type check…
…ing tests, a=testonly Automatic update from web-platform-tests Update and expand worker MIME type checking tests Follows whatwg/html#5302. -- wpt-commits: 031409f5be576b09f592f114e50c241db96820c5 wpt-pr: 24983
- Loading branch information
1 parent
b458e2f
commit 959830f
Showing
1 changed file
with
30 additions
and
11 deletions.
There are no files selected for viewing
41 changes: 30 additions & 11 deletions
41
testing/web-platform/tests/workers/Worker_script_mimetype.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
<!DOCTYPE html> | ||
<title> Worker constructor with script inside text file </title> | ||
<title>Worker constructor with wrong MIME type scripts</title> | ||
<meta charset="utf-8"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id=log></div> | ||
|
||
<script> | ||
async_test(function(t) { | ||
var worker = new Worker('./support/WorkerText.txt'); | ||
worker.onmessage = t.step_func_done(function(e) { | ||
assert_equals(e.data, "Pass"); | ||
}); | ||
// TODO(mkwst): Revisit this after https://github.com/whatwg/html/issues/3255. | ||
worker.onerror = t.unreached_func("Worker should load."); | ||
worker.postMessage("start"); | ||
}); | ||
async_test(t => { | ||
const worker = new Worker('./support/WorkerText.txt'); | ||
worker.onmessage = t.unreached_func("Worker should not recieve messages"); | ||
worker.onerror = () => t.done(); | ||
}, "HTTP(S) URLs which respond with text/plain MIME type must not work"); | ||
|
||
async_test(t => { | ||
const url = URL.createObjectURL(new Blob(['postMessage("PASS")'])); // no MIME type parameter | ||
const worker = new Worker(url); | ||
worker.onmessage = () => t.done(); | ||
worker.onerror = t.unreached_func("Worker should not error"); | ||
}, "blob: URLs should load, despite no MIME type for the backing Blob"); | ||
|
||
async_test(t => { | ||
const url = URL.createObjectURL(new Blob(['postMessage("PASS")'], { type: 'text/plain' })); | ||
const worker = new Worker(url); | ||
worker.onmessage = () => t.done(); | ||
worker.onerror = t.unreached_func("Worker should not error"); | ||
}, "blob: URLs should load, despite the wrong MIME type for the backing Blob"); | ||
|
||
async_test(t => { | ||
const url = `data:text/plain,postMessage("PASS");` | ||
const worker = new Worker(url); | ||
worker.onmessage = () => t.done(); | ||
worker.onerror = t.unreached_func("Worker should not error"); | ||
}, "data: URLs should load, despite the wrong MIME type"); | ||
|
||
</script> |