summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-allowed.html
blob: 633fa85e6acd6c5dd9cfcd1dfd9929abf15214f8 (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
31
32
33
34
35
36
37
<!DOCTYPE html>
<style>
#spacer {
  width: 200%;
  height: 200%;
}
</style>
<body>
<script>
  window.addEventListener("message", onMessageReceived);

  function test(api, args) {
    let did_throw = false;
    try {
     document[api](args);
    } catch(e) {
      did_throw = true;
    }
    return did_throw;
  }

  function onMessageReceived(e) {
    let msg = e.data;

    msg.did_throw_exception = test(msg.api, msg.args);
    if (msg.query) {
      let el = document.querySelector(msg.query);
      msg.value = el ? el.innerHTML : false;
    }
    ackMessage(msg, e.source);
  }

  function ackMessage(msg, source) {
    source.postMessage(msg, "*");
  }
</script>
</body>