MCPcopy Index your code
hub / github.com/MALSync/MALSync / singleCase

Function singleCase

test/headless/test.js:359–496  ·  view source on GitHub ↗
(block, test, page, testPage, retry = 0)

Source from the content-addressed store, hash-verified

357}
358
359async function singleCase(block, test, page, testPage, retry = 0) {
360 const saveCallback = await PreparePage(block, page, test.url, testPage);
361 const testJquery = () => page.evaluate(() => {
362 if (typeof jQuery === 'undefined') throw 'jquery could not be loaded';
363 })
364
365 await page
366 .addScriptTag({
367 content: fs.readFileSync(`./node_modules/jquery/dist/jquery.min.js`, 'utf8'),
368 })
369 .then(() => {
370 return testJquery();
371 }).catch(async () => {
372 await page.evaluate(fs.readFileSync(`./node_modules/jquery/dist/jquery.min.js`, 'utf8'));
373 await testJquery();
374 });
375
376 const loadContent = await page.evaluate(() => document.body.innerHTML);
377
378 if (loadContent.indexOf('>nginx<') !== -1) {
379 log(block, 'nginx error', 2);
380 throw 'Blocked';
381 }
382
383 await page.evaluate(() => console.log(`Adding chrome api`));
384 await page.addScriptTag({
385 content: `
386 window.chrome = {
387 runtime: {
388 onMessage: {
389 addListener: function(callback) {
390 console.log('chrome.runtime.onMessage.addListener', callback);
391 }
392 },
393 sendMessage: function(message, callback) {
394 console.log('chrome.runtime.sendMessage', message, callback);
395 },
396 getURL: function(path) {
397 console.log('chrome.runtime.getURL', path);
398 return '';
399 },
400 getManifest: function() {
401 console.log('chrome.runtime.getManifest');
402 return {
403 version: '10.1.1',
404 };
405 }
406 },
407 storage: {
408 local: {
409 get: function(keys, callback) {
410 console.log('chrome.storage.local.get', keys, callback);
411 callback({});
412 return promise.resolve({});
413 },
414 set: function(items, callback) {
415 console.log('chrome.storage.local.set', items, callback);
416 if (callback) {

Callers 1

testPageCaseFunction · 0.85

Calls 5

PreparePageFunction · 0.85
testJqueryFunction · 0.85
logFunction · 0.85
keysMethod · 0.80
cdnFunction · 0.70

Tested by

no test coverage detected