Skip to content

Commit

Permalink
test: add debug checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jan 18, 2022
1 parent 4ed10a4 commit ccd77bf
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions tests/benchmarks/services/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
}
table {
border-spacing: 0;
margin-bottom: 30px;
}
td,
th {
Expand Down Expand Up @@ -75,14 +74,27 @@
color: blue;
border-color: blue;
}
label {
margin: 0;
padding: 0;
}
label span {
position: relative;
}
label span input {
position: absolute;
margin: 1px 0 0 6px;
}
</style>
</head>
<body>
<h1>Services Benchmark</h1>

<p>
Combine various services together on this page so it can be page speed tested. "Standard" runs
the service as a traditional script, and "Partytown" will run it with "text/partytown".
the service as a traditional script, and "Partytown" will run it with "text/partytown". Debug
Mode uses Partytown's debug script, which has no minification, the web worker is not inlined,
and prints more console logs.
</p>

<template id="fbp">
Expand Down Expand Up @@ -179,6 +191,7 @@ <h1>Services Benchmark</h1>
}
},
forward: ['fbq', 'dataLayer.push', '_wq.push'],
debug: document.getElementById('debug-mode').checked,
};
/* Partytown 0.2.0 - MIT builder.io */
// prettier-ignore
Expand Down Expand Up @@ -213,6 +226,15 @@ <h1>Services Benchmark</h1>
</a>
</p>

<p>
<label
>Debug Mode:
<span>
<input type="checkbox" id="debug-mode" />
</span>
</label>
</p>

<p id="user-agent"></p>

<p>
Expand All @@ -233,6 +255,7 @@ <h1>Services Benchmark</h1>

const url = new URL(location.href);
const table = document.getElementById('services');
const debugMode = document.getElementById('debug-mode');
let includePartytownScript = false;

document.getElementById('user-agent').textContent = navigator.userAgent;
Expand Down Expand Up @@ -268,6 +291,9 @@ <h1>Services Benchmark</h1>
.forEach((radio) => {
url.searchParams.set(radio.name, radio.value);
});
if (debugMode.checked) {
url.searchParams.set('debug', 'true');
}
location = url.href;
}

Expand Down Expand Up @@ -318,6 +344,9 @@ <h1>Services Benchmark</h1>
table.appendChild(tr);
});

debugMode.checked = url.searchParams.has('debug');
debugMode.addEventListener('change', serviceChange);

if (includePartytownScript) {
const partytownScript = document.createElement('script');
partytownScript.dataset.id = 'partytown';
Expand Down

1 comment on commit ccd77bf

@vercel
Copy link

@vercel vercel bot commented on ccd77bf Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.