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
   66
   67
   68
   69
   70
   71
   72
   73

content / test / data / click-nocontent-link.html [blame]

<html>

 <head><title>Click nocontent link</title>
 <script>
  function simulateClick(target) {
    var evt = document.createEvent("MouseEvents");
    evt.initMouseEvent("click", true, true, window,
                       0, 0, 0, 0, 0, false, false,
                       false, false, 0, null);

    return target.dispatchEvent(evt);
  }

  function clickNoContentTargetedLink() {
    return simulateClick(document.getElementById("nocontent_targeted_link"));
  }

  function clickNoContentScriptedTargetedLink() {
    return simulateClick(document.getElementById(
        "nocontent_scripted_targeted_link"));
  }

  function getNewWindowReference() {
    // Grab a reference to the existing foo window, but don't otherwise access
    // it in any way.
    var w = window.open("", "foo");
    // w is intentionally unused after this point to avoid triggering a call to
    // DidAccessInitialDocument().

    // Modify the title to give the test a notification to listen for. Use a
    // timeout so that any DidAccessInitialDocument() notification arrives
    // first. Note that this intentionally uses |window| instead of |w| to avoid
    // test boilerplate from triggering calls to DidAccessInitialDocument().
    setTimeout(function() { window.document.title = "Modified Title"; });
  }

  function modifyNewWindow() {
    // Grab a reference to the existing foo window and modify its content.
    var w = window.open("", "foo");
    w.document.body.innerHTML += "Modified";

    // Modify the title to give the test a notification to listen for. Use a
    // timeout so that any DidAccessInitialDocument() notification arrives
    // first. Note that this intentionally uses |window| instead of |w| to avoid
    // test boilerplate from triggering calls to DidAccessInitialDocument().
    setTimeout(function() { window.document.title = "Modified Title"; });
  }

  function modifyNewWindowWithDocumentOpen() {
    // Grab a reference to the existing foo window and modify its content.
    var w = window.open("", "foo");
    w.document.open();
    w.document.write("Modified");
    w.document.close();

    // Modify the title to give the test a notification to listen for. Use a
    // timeout so that any DidAccessInitialDocument() notification arrives
    // first. Note that this intentionally uses |window| instead of |w| to avoid
    // test boilerplate from triggering calls to DidAccessInitialDocument().
    setTimeout(function() { window.document.title = "Modified Title"; });
  }
 </script>
 </head>

<a href="/nocontent" id="nocontent_targeted_link" target="foo">
  /nocontent target=foo</a><br>
<button onclick="modifyNewWindow()">Modify New Window</button><br>

<a href="/nocontent" id="nocontent_scripted_targeted_link" target="foo"
   onclick="modifyNewWindow()">
  /nocontent scripted target=foo</a><br>

</html>