odeURIComponent(code);
  const afterReplacementURL = "/common/blank.html?thereplacement";
  const iframe = insertIframe(t, startURL);

  assert_equals(history.length, startingHistoryLength, "Inserting the under-test iframe must not change history.length");

  const absoluteStartURL = (new URL(startURL, location.href)).href;
  while (true) {
    if (iframe.contentWindow.location.href === absoluteStartURL) {
      break;
    }
    await new Promise(r => setTimeout(r, 0));
  }

  assert_equals(iframe.contentWi