summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-locks/resources/partitioned-parent.html
blob: ec19c8dbaa69bb2d3b31c8c508f65f2bece23adb (plain)
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
<!DOCTYPE html>
<meta charset="utf-8"/>
<meta name="referrer" content="origin">
<script>
async function onLoad() {
  // Step 6 and Nested Step 9:
  // wpt/web-locks/partitioned-web-locks.tentative.https.html
  self.addEventListener('message', evt => {
    if (self.opener)
      self.opener.postMessage(evt.data, '*');
    else
      self.top.postMessage(evt.data, '*');
  }, { once: true });

  // Step 3 and Nested Step 3:
  // wpt/web-locks/partitioned-web-locks.tentative.https.html
  const params = new URLSearchParams(self.location.search);
  const frame = document.createElement('iframe');
  frame.src = params.get('target');
  document.body.appendChild(frame);

  // Step 4 and Nested Step 4:
  // wpt/web-locks/partitioned-web-locks.tentative.https.html
  frame.addEventListener('load', function(){
    frame.contentWindow.postMessage({op: 'request',
        name: 'testLock', ifAvailable: true}, '*');
  });
}
self.addEventListener('load', onLoad);
</script>