From 5835721322dbc72faa1cc3ba4200c760efb05d9c Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 3 Feb 2022 15:01:29 +0530 Subject: [PATCH] Updated checkup page tests 1. check that /api/config is reachable from the sandbox domain 2. check that interest-cohort rules are present rather than strict comparison of expected headers --- www/checkup/main.js | 18 ++++++++++++++++-- www/checkup/sandbox/main.js | 9 +++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/www/checkup/main.js b/www/checkup/main.js index f490014c1..8d8452726 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -420,9 +420,11 @@ define([ $.ajax('/?'+ (+new Date()), { complete: function (xhr) { - var header = xhr.getResponseHeader('permissions-policy'); + var header = xhr.getResponseHeader('permissions-policy') || ''; + var rules = header.split(','); + if (rules.includes('interest-cohort=()')) { return void cb(true); } printMessage(JSON.stringify(header)); - cb(header === 'interest-cohort=()' || header); + cb(header); }, }); }); @@ -896,6 +898,18 @@ define([ }); }); + assert(function (cb, msg) { + msg.appendChild(h('span', 'pewpew')); + deferredPostMessage({ + command: 'CHECK_HTTP_STATUS', + content: { + url: cacheBuster('/api/config'), + }, + }, function (content) { + cb(content === 200 || content); + }); + }); + /* assert(function (cb, msg) { setWarningClass(msg); diff --git a/www/checkup/sandbox/main.js b/www/checkup/sandbox/main.js index 272db91a4..47a7be13b 100644 --- a/www/checkup/sandbox/main.js +++ b/www/checkup/sandbox/main.js @@ -48,6 +48,15 @@ define([ }); }; + COMMANDS.CHECK_HTTP_STATUS = function (content, cb) { + $.ajax(content.url, { + dataType: 'text', + complete: function (xhr) { + cb(xhr.status); + }, + }); + }; + window.addEventListener("message", function (event) { var txid, command; if (event && event.data) {