fgnass / domino

Server-side DOM implementation based on Mozilla's dom.js
BSD 2-Clause "Simplified" License
769 stars 120 forks source link

support: understanding iframes #164

Open gcbw opened 4 years ago

gcbw commented 4 years ago

I am trying to understand why this code asserts true.

    var parentwin = domino.createWindow('<h1>parent</h1><iframe id="frm" src="http://example.com/child.html"></iframe>', 'http://example.com/parent.html');
    var window = parentwin.document.getElementById('frm')._contentWindow;
    window.location.href = 'http://example.com/child.html';

    assert.equal(window.top, window.self);

i'm running this on mocha, over node12.

debugging i can confirm that at the time of assert, both window.top and window.self shows the same object (having location.href=child.html.

what am i doing wrong here? Is there a better way to mock a window with a parent window similar to an iframe relation for a test?

gcbw commented 4 years ago

found this test, but it doesn't touch the .top .parent properties either https://github.com/fgnass/domino/blob/a18b920595db62d26a79c0836deaf997a78d29ce/test/web-platform-tests.js#L145

gcbw commented 4 years ago

installed webstrom to make sure i had a decent debugger without a browser.

Screen Shot 2020-04-30 at 16 27 22
gcbw commented 4 years ago

guessing there's no support for nesting. Is this something we might want to add (i assumed it was already supported because of the w3c tests)

https://github.com/fgnass/domino/blob/master/lib/Window.js#L32

cscott commented 4 years ago

domino doesn't generally do loading, by design. If there's some useful improvements to the handling of <iframe> which doesn't involve loading content from its src, I'm certainly open to them, especially if they are standards-based.

gcbw commented 4 years ago

don't care about the loading either (the test reset the location just to id them). mostly the nesting is what matters.