MCPcopy
hub / github.com/ampproject/amphtml / runVideoTestBench

Function runVideoTestBench

build-system/server/app-video-testbench.js:354–386  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

352
353
354function runVideoTestBench(req, res, next) {
355 fs.promises.readFile(sourceFile).then(contents => {
356 const dom = new JSDOM(contents);
357 const {window} = dom;
358 const doc = window.document;
359
360 const {extension} = req.query;
361
362 setOptionalAttrs(req, doc);
363
364 if (extension) {
365 if (!isValidExtension(extension)) {
366 res.status(403);
367 res.end('Invalid extension parameter.');
368 return;
369 }
370 replaceExtension(doc, extension);
371 }
372
373 const dropdownContainer = doc.querySelector('.dropdown-container');
374 dropdownContainer.appendChild(renderExtensionDropdown(doc), extension);
375
376 const optionalAttrsContainer =
377 doc.querySelector('.optional-attrs-container');
378 optionalAttrsContainer.appendChild(renderOptionalAttrsCheckboxes(doc));
379
380 appendClientScript(doc);
381
382 return res.end(replaceUrls(getServeMode(), dom.serialize()));
383 }).catch(() => {
384 next();
385 });
386}
387
388
389module.exports = runVideoTestBench;

Callers

nothing calls this directly

Calls 11

setOptionalAttrsFunction · 0.85
isValidExtensionFunction · 0.85
replaceExtensionFunction · 0.85
renderExtensionDropdownFunction · 0.85
appendClientScriptFunction · 0.85
getServeModeFunction · 0.85
catchMethod · 0.80
replaceUrlsFunction · 0.70
nextFunction · 0.50
thenMethod · 0.45

Tested by

no test coverage detected