Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext-in-worker.html

Issue 2271593002: Convert OffscreenCanvas-getContext tests to testharness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed test as per the comments. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests that the 2D and webgl context of OffscreenCanvas can be constructed on a worker thread.</title>
3 <script src="../../resources/js-test.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <body> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script id="myWorker" type="text/worker"> 5 <script>
6 self.onmessage = function(e) { 6 fetch_tests_from_worker(new Worker("OffscreenCanvas-getContext-in-worker.js"));
7 var aCanvas = new OffscreenCanvas(50, 50);
8 var bCanvas = new OffscreenCanvas(50, 50);
9 try {
10 var ctx1 = aCanvas.getContext('2d');
11 var ctx2 = bCanvas.getContext('webgl');
12 if (!(ctx1 instanceof OffscreenCanvasRenderingContext2D)) {
13 self.postMessage("aCanvas.getContext('2d') returns " + ctx1);
14 } else if (!(ctx2 instanceof WebGLRenderingContext)) {
15 self.postMessage("bCanvas.getContext('webgl') returns " + ctx2);
16 } else {
17 self.postMessage("success");
18 }
19 } catch (e) {
20 self.postMessage(e);
21 }
22 };
23 </script> 7 </script>
24
25 <script>
26 jsTestIsAsync = true;
27 description("Tests that the 2D and webgl context of OffscreenCanvas can be const ructed on a worker thread.");
28
29 function makeWorker(script) {
30 var blob = new Blob([script]);
31 return new Worker(URL.createObjectURL(blob));
32 }
33
34 function handleMessageFromWorker(msg)
35 {
36 if (msg.data == "success") {
37 testPassed("getContext('2d') and getContext('webgl') works on a worker t hread");
38 } else {
39 testFailed(msg.data);
40 }
41 finishJSTest();
42 }
43
44 var worker = makeWorker(document.getElementById('myWorker').textContent);
45 worker.addEventListener('message', handleMessageFromWorker);
46 worker.postMessage("");
47 </script>
48
49 </body>
50 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698