Skip to content

iframe's contentWindow property is null right after creating iframe #7162

Closed

Description

@sole

I'm trying to make sure I don't access an iframe before it's ready so I'm adding a listener to its contentWindow 'load' event. This code works fine in Firefox:

fr.contentWindow.addEventListener('load', function() {
    fr.contentWindow.postMessage('hey', '*');
});

but it fails in Servo with
ERROR:js::rust: Error at file:///Users/sole/data/servodemos/gradient/js/main.js:17: TypeError: fr.contentWindow is null

I tried just modifying the onload property on the iframe and that works instead!

fr.onload = function() {
    console.log('hello');
};

Activity

  1. added
    A-content/dom
    I-panic
    I-wrong
    and removed
    I-panic
    on Aug 11, 2015
  2. Manishearth commented on Aug 11, 2015

    @Manishearth
    Member

    This is mostly a dupe of #5500 (different bug, same source)

  3. jdm commented on Aug 11, 2015

    @jdm
    Member

    Thanks for reporting this! We already track this in #5500 (and specifically #5240), and I don't think there's any new information present here, so I'll close this as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domI-wrong

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions