2019-12-24 00:54:17 +01:00
|
|
|
/* globals iframeAPI*/
|
2019-12-16 19:27:28 +01:00
|
|
|
const createLog = function(){
|
2019-02-27 23:49:00 +01:00
|
|
|
"use strict";
|
|
|
|
|
2019-12-16 19:27:28 +01:00
|
|
|
const div = document.getElementById("log");
|
2019-02-27 23:49:00 +01:00
|
|
|
|
|
|
|
return function createLog(){
|
2019-12-16 19:27:28 +01:00
|
|
|
const logDiv = document.createElement("div");
|
2019-02-27 23:49:00 +01:00
|
|
|
logDiv.className = "log";
|
|
|
|
div.appendChild(logDiv);
|
|
|
|
return function createLine(str){
|
2019-12-16 19:27:28 +01:00
|
|
|
const logLine = document.createElement("div");
|
2019-02-27 23:49:00 +01:00
|
|
|
logLine.className = "logLine";
|
|
|
|
logDiv.appendChild(logLine);
|
|
|
|
logLine.textContent = str;
|
2019-12-21 23:47:07 +01:00
|
|
|
return {
|
|
|
|
update: function updateLine(str){
|
|
|
|
str = str.replace("{old content}", logLine.textContent);
|
|
|
|
logLine.textContent = str;
|
|
|
|
},
|
2019-12-24 00:54:17 +01:00
|
|
|
mark: function mark(marktext){
|
2019-12-21 23:47:07 +01:00
|
|
|
logLine.classList.add("marked");
|
2019-12-24 00:54:17 +01:00
|
|
|
logLine.title += marktext + "\n";
|
2019-12-21 23:47:07 +01:00
|
|
|
}
|
2019-02-27 23:49:00 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}();
|
|
|
|
|
2019-12-21 23:47:07 +01:00
|
|
|
const log = createLog();
|
2019-02-27 23:49:00 +01:00
|
|
|
|
2019-12-21 23:47:07 +01:00
|
|
|
const userAgentIsConsistent = document.getElementById("serverUserAgent").text === navigator.userAgent;
|
|
|
|
const consistencyLine = log("user agent equal between server and client: " + userAgentIsConsistent);
|
|
|
|
if (!userAgentIsConsistent){
|
|
|
|
consistencyLine.mark();
|
|
|
|
}
|
|
|
|
const lines = {};
|
2019-12-24 00:54:17 +01:00
|
|
|
|
2020-04-13 10:10:44 +02:00
|
|
|
function processNavigatorObject(navigator, keys, name){
|
2019-05-22 23:39:56 +02:00
|
|
|
"use strict";
|
2020-04-13 10:10:44 +02:00
|
|
|
|
|
|
|
keys.sort().forEach(function(property){
|
2019-12-21 23:47:07 +01:00
|
|
|
const value = navigator[property];
|
|
|
|
if ((typeof value) === "string"){
|
|
|
|
if (!lines[property]){
|
|
|
|
lines[property] = {
|
|
|
|
values: [],
|
|
|
|
log: log(property + ": ")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const propertyLine = lines[property];
|
|
|
|
if (propertyLine.values.indexOf(value) === -1){
|
|
|
|
propertyLine.log.update("{old content}" + (propertyLine.values.length? " | ": "") + value);
|
|
|
|
propertyLine.values.push(value);
|
|
|
|
}
|
|
|
|
if (propertyLine.values[0] !== value){
|
2019-12-24 00:54:17 +01:00
|
|
|
propertyLine.log.mark("failed test " + name);
|
2019-12-21 23:47:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-04-13 10:10:44 +02:00
|
|
|
}
|
|
|
|
|
2024-03-30 13:58:09 +01:00
|
|
|
iframeAPI.forEachMethod(async function(windowToUse, name){
|
2020-04-13 10:10:44 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const navigator = windowToUse.navigator;
|
2024-03-30 13:58:09 +01:00
|
|
|
const values = {};
|
|
|
|
const keys = Object.keys(navigator.__proto__);
|
|
|
|
keys.forEach(function(property){
|
|
|
|
const value = navigator[property];
|
|
|
|
if ((typeof value) === "string"){
|
|
|
|
values[property] = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const storage = await navigator.storage.estimate();
|
|
|
|
values.storage_quota = storage.quota.toString(10);
|
|
|
|
keys.push("storage_quota");
|
|
|
|
console.log(name, values);
|
|
|
|
processNavigatorObject(values, keys, name);
|
2020-04-13 10:10:44 +02:00
|
|
|
});
|
|
|
|
|
2020-04-15 00:25:24 +02:00
|
|
|
function processWorkerNavigatorObject(data, name){
|
|
|
|
"use strict";
|
2024-03-30 13:58:09 +01:00
|
|
|
console.log(name, data);
|
2020-04-15 00:25:24 +02:00
|
|
|
processNavigatorObject(data.values, Object.keys(data.values), name);
|
|
|
|
if (data.nestedValues){
|
|
|
|
processWorkerNavigatorObject(data.nestedValues, "nested " + name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const worker = new Worker("navigatorTestWorker.js", {name: "Worker"});
|
2020-04-13 10:10:44 +02:00
|
|
|
worker.addEventListener("message", function(event){
|
|
|
|
"use strict";
|
|
|
|
|
2020-04-15 00:25:24 +02:00
|
|
|
processWorkerNavigatorObject(event.data, "Worker");
|
2020-04-13 10:10:44 +02:00
|
|
|
worker.terminate();
|
|
|
|
});
|
|
|
|
|
2020-04-15 00:25:24 +02:00
|
|
|
fetch("navigatorTestWorker.js").then(function(response){
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
return response.text();
|
|
|
|
}).then(function(code){
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const blob = new Blob([code], {type: "text/javascript"});
|
|
|
|
const blobWorker = new Worker(URL.createObjectURL(blob), {name: "BlobWorker"});
|
|
|
|
blobWorker.addEventListener("message", function(event){
|
|
|
|
processWorkerNavigatorObject(event.data, "BlobWorker");
|
|
|
|
blobWorker.terminate();
|
|
|
|
});
|
|
|
|
|
|
|
|
return blobWorker;
|
|
|
|
}).catch(function(error){
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
console.error("Unable to create BlobWorker:", error);
|
|
|
|
});
|
|
|
|
|
|
|
|
const sharedWorker = new SharedWorker("navigatorTestWorker.js", {name: "SharedWorker"});
|
2020-04-13 10:10:44 +02:00
|
|
|
sharedWorker.port.addEventListener("message", function(event){
|
|
|
|
"use strict";
|
|
|
|
|
2020-04-15 00:25:24 +02:00
|
|
|
processWorkerNavigatorObject(event.data, "SharedWorker");
|
2020-04-13 10:10:44 +02:00
|
|
|
sharedWorker.port.close();
|
|
|
|
});
|
|
|
|
sharedWorker.port.start();
|
|
|
|
|
|
|
|
navigator.serviceWorker.register("navigatorTestWorker.js").then(function(registration){
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const worker = (registration.active || registration.waiting || registration.installing);
|
|
|
|
navigator.serviceWorker.addEventListener("message", function(event){
|
2020-04-15 00:25:24 +02:00
|
|
|
processWorkerNavigatorObject(event.data, "ServiceWorker");
|
2020-04-13 10:10:44 +02:00
|
|
|
registration.unregister();
|
|
|
|
});
|
|
|
|
if (worker.state !== "activated"){
|
|
|
|
worker.addEventListener("statechange", function(){
|
|
|
|
if (worker.state === "activated"){
|
|
|
|
worker.postMessage("send");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
worker.postMessage("send");
|
|
|
|
}
|
|
|
|
return registration;
|
|
|
|
}).catch(function(error){
|
|
|
|
"use strict";
|
|
|
|
console.error("Unable to register service worker:", error);
|
2019-05-22 23:39:56 +02:00
|
|
|
});
|