Response Header Size Script
storeHome Page stepName1
openhttps://www.bluetriangle.com/
waitForElementPresentcss=body
pause3000
runScriptfunction checkHeaderSize(thresholdBytes) { var request = new XMLHttpRequest(); request.open('GET', document.location, false); request.send(null); var headers = request.getAllResponseHeaders().toLowerCase(); var headersBytes = (new TextEncoder().encode(headers)).length; var customId = ""; var customMessage = ""; var threshold = thresholdBytes; if (headersBytes < threshold) { customColor = "green"; customId = "response-header-size-check-passed"; customMessage = "Pass. Observed response header size " + headersBytes + " is less than threshold of " + threshold + "."; } else if (headersBytes > threshold) { customColor = "red"; customId = "response-header-size-check-failed"; customMessage = "Fail. Observed response header size " + headersBytes + " is greater than threshold of " + threshold + "."; } else { customColor = "blue "; customId = "response-header-size-check-error"; customMessage = "Error retrieving response header data"; } var messageNode = document.createElement("div"); messageNode.innerHTML = "<h2 style='color:" + customColor + ";' id='" + customId + "'>" + customMessage + "</h2>"; document.querySelector('header').firstElementChild.prepend(messageNode); console.log(customMessage); }; checkHeaderSize(8000);
assertElementPresentid=response-header-size-check-passed
storeReal User MonitoringstepName2
openhttps://www.bluetriangle.com/products/real-user-monitoring/
waitForElementPresentcss=body
pause3000
runScriptfunction checkHeaderSize(thresholdBytes) { var request = new XMLHttpRequest(); request.open('GET', document.location, false); request.send(null); var headers = request.getAllResponseHeaders().toLowerCase(); var headersBytes = (new TextEncoder().encode(headers)).length; var customId = ""; var customMessage = ""; var threshold = thresholdBytes; if (headersBytes < threshold) { customColor = "green"; customId = "response-header-size-check-passed"; customMessage = "Pass. Observed response header size " + headersBytes + " is less than threshold of " + threshold + "."; } else if (headersBytes > threshold) { customColor = "red"; customId = "response-header-size-check-failed"; customMessage = "Fail. Observed response header size " + headersBytes + " is greater than threshold of " + threshold + "."; } else { customColor = "blue "; customId = "response-header-size-check-error"; customMessage = "Error retrieving response header data"; } var messageNode = document.createElement("div"); messageNode.innerHTML = "" + customMessage + ""; document.querySelector('header').firstElementChild.prepend(messageNode); console.log(customMessage); }; checkHeaderSize(100);
assertElementPresentid=response-header-size-check-passed