Changeset 294742 in webkit
- Timestamp:
- May 24, 2022, 6:08:49 AM (4 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 3 edited
-
fast/canvas/canvas-createPattern-video-loading.html (modified) (4 diffs)
-
fast/canvas/canvas-createPattern-video-modify.html (modified) (3 diffs)
-
media/utilities.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading.html
r284439 r294742 4 4 <script src="../../resources/js-test-pre.js"></script> 5 5 <script src="../../media/media-file.js"></script> 6 <script src="../../media/utilities.js"></script> 6 7 <script src="../../resources/platform-helper.js"></script> 7 8 </head> … … 33 34 34 35 var video = document.createElement("video"); 35 video.addEventListener("loadeddata", loadeddata);36 video.addEventListener("playing", playing);37 36 38 37 shouldBeNull("document.createElement('canvas').getContext('2d').createPattern(video, 'repeat')"); 39 38 39 waitForVideoFrame(video, firstframe); 40 40 video.src = findMediaFile("video", "../../media/content/test"); 41 41 42 42 43 function checkPixels(context, x, y, r, g, b, tolerance) … … 64 65 } 65 66 66 function loadeddata()67 async function firstframe() 67 68 { 68 69 drawImageToCanvasAndCheckPixels(); … … 70 71 video.currentTime = 1; 71 72 video.play(); 72 } 73 74 function playing() 75 { 73 await waitForVideoFrameUntil(video, 1); 76 74 video.pause(); 77 75 -
trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify.html
r284439 r294742 4 4 <script src="../../resources/js-test-pre.js"></script> 5 5 <script src="../../media/media-file.js"></script> 6 <script src="../../media/utilities.js"></script> 6 7 <script src="../../resources/platform-helper.js"></script> 7 8 </head> … … 12 13 var buffer; 13 14 var canvas, context; 14 var modified = false;15 15 var expectedResults = [ 16 16 // Each entry is formatted as [x, y, r, g, b]. … … 22 22 23 23 var video = document.createElement("video"); 24 video.addEventListener("loadeddata", loadeddata); 24 25 waitForVideoFrame(video, firstframe); 25 26 video.src = findMediaFile("video", "../../media/content/test"); 26 27 27 function loadeddata()28 async function firstframe() 28 29 { 29 if (!modified) { 30 canvas = document.createElement("canvas"); 31 canvas.width = 2.5 * video.videoWidth; 32 canvas.height = 2.5 * video.videoHeight; 33 document.body.appendChild(canvas); 30 canvas = document.createElement("canvas"); 31 canvas.width = 2.5 * video.videoWidth; 32 canvas.height = 2.5 * video.videoHeight; 33 document.body.appendChild(canvas); 34 34 35 context = canvas.getContext("2d");36 context.fillStyle = context.createPattern(video, "repeat");35 context = canvas.getContext("2d"); 36 context.fillStyle = context.createPattern(video, "repeat"); 37 37 38 video.src = findMediaFile("video", "../../media/content/counting"); 39 modified = !modified; 40 } else { 41 context.fillRect(0, 0, canvas.width, canvas.height); 38 video.src = findMediaFile("video", "../../media/content/counting"); 42 39 43 expectedResults.forEach(function(element) { 44 checkPixels(context, element[0], element[1], element[2], element[3], element[4], videoCanvasPixelComparisonTolerance()); 45 }); 40 await waitForVideoFrame(video); 46 41 47 finishJSTest(); 48 } 42 context.fillRect(0, 0, canvas.width, canvas.height); 43 expectedResults.forEach(function(element) { 44 checkPixels(context, element[0], element[1], element[2], element[3], element[4], videoCanvasPixelComparisonTolerance()); 45 }); 46 47 finishJSTest(); 49 48 } 50 49 -
trunk/LayoutTests/media/utilities.js
r291216 r294742 5 5 }, { once: true }); 6 6 }); 7 if (cb) {7 if (cb) 8 8 p.then(cb); 9 }10 9 return p; 11 10 } … … 22 21 }); 23 22 24 if (onLoadFunction) {23 if (onLoadFunction) 25 24 p.then(onLoadFunction); 26 }27 25 28 26 return p; … … 43 41 let buffers = {}; 44 42 let fetches = []; 45 for (var chunk of chunks) {43 for (var chunk of chunks) 46 44 fetches.push(fetchWithXHR(prefix + chunk + suffix).then(((c, x) => buffers[c] = x).bind(null, chunk))); 47 }48 45 49 46 // Load them in series, as required per spec. 50 47 return Promise.all(fetches).then(() => { 51 48 let rv = Promise.resolve(); 52 for (let chunk of chunks) {49 for (let chunk of chunks) 53 50 rv = rv.then(loadSegment.bind(null, sb, buffers[chunk])); 54 }55 51 return rv; 56 52 }); … … 58 54 59 55 const delay = ms => new Promise(res => setTimeout(res, ms)); 56 57 function waitForVideoFrame(video, cb) { 58 const p = new Promise((resolve) => { 59 video.requestVideoFrameCallback((now, metadata) => resolve(now, metadata)); 60 }); 61 if (cb) 62 p.then(cb); 63 return p; 64 } 65 66 function waitForVideoFrameUntil(video, time, cb) { 67 const p = new Promise(resolve => { 68 const callback = ((now, metadata) => { 69 if (metadata.mediaTime >= time) { 70 resolve(now, metadata); 71 return; 72 } 73 video.requestVideoFrameCallback(callback); 74 }); 75 video.requestVideoFrameCallback(callback); 76 }); 77 if (cb) 78 p.then(cb); 79 return p; 80 }
Note:
See TracChangeset
for help on using the changeset viewer.