DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
<!DOCTYPE HTML>
<html>
  <head>
    <title>GV autoplay play request test</title>
    <script src="/tests/SimpleTest/SimpleTest.js"></script>
    <script src="/tests/SimpleTest/EventUtils.js"></script>
    <script type="text/javascript" src="manifest.js"></script>
    <script type="text/javascript" src="AutoplayTestUtils.js"></script>
  </head>
<body>
<script>
/**
 * The test info sent from the parent window will determine what kinds of media
 * should start, where it should start, the result of the play request and
 * whether the document is activated by user gesture.
 */
nextWindowMessage().then(
  async (event) => {
    let testInfo = event.data;
    testInfo.parentWindow = event.source;
    await setupTestEnvironment(testInfo);
    await startPlaybackAndReturnMessage(testInfo);
  });

/**
 * The following are helper functions.
 */
async function setupTestEnvironment(testInfo) {
  if (testInfo.activatedDocument != undefined) {
    info(`activate document`);
    SpecialPowers.wrap(document).notifyUserGestureActivation();
  }
  if (testInfo.iframe != undefined) {
    info(`create child frame`);
    testInfo.childFrame = await createChildFrame(testInfo);
  }
}

async function createChildFrame(testInfo) {
  let frame = document.createElement("iframe");
  let origin = testInfo.iframe == "same-orgin"
    ? "http://mochi.test:8888" : "http://example.org";
  frame.src = origin + "/tests/dom/media/test/file_autoplay_gv_play_request_frame.html";
  document.body.appendChild(frame);
  info(`waiting for iframe loading`);
  is((await nextWindowMessage()).data, "ready", "iframe has finished loading");
  return frame;
}

async function startPlaybackAndReturnMessage({muted, iframe, parentWindow, childFrame}) {
  if (iframe == undefined) {
    info(`start playback`);
    playAndPostResult(muted, parentWindow);
  } else {
    info("start autoplay from " +  (iframe == "same-origin" ? "same" : "cross")  + " origin child frame");
    childFrame.contentWindow.postMessage("play", "*");
    info(`waiting for media calling play from child frame`);
    let result = await nextWindowMessage();
    parentWindow.postMessage(result.data, "*");
  }
}

</script>
</body>
</html>