Skip to content

Commit

Permalink
Bug 1589102 - Part 6: Do not load more than 2 nested frames in browse…
Browse files Browse the repository at this point in the history
…r_browsingContext-01.js test, r=farre

Creating more than 2 nested iframes is not allowed and is now enforced for
about:blank loads because they now take place via DocumentChannel.

Differential Revision: https://phabricator.services.mozilla.com/D85084
  • Loading branch information
annygakh committed Aug 5, 2020
1 parent 5da2f83 commit a7d4d40
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions docshell/test/browser/browser_browsingContext-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ async function addFrame(browser, id, parentId) {
parent = content.document.body;
}

let frame = content.document.createElement("iframe");
frame.id = id || "";
frame.url = "about:blank";
parent.appendChild(frame);
let frame = await new Promise(resolve => {
let frame = content.document.createElement("iframe");
frame.id = id || "";
frame.url = "about:blank";
frame.onload = () => resolve(frame);
parent.appendChild(frame);
});

return frame.contentWindow.docShell.browsingContext.id;
});
Expand Down Expand Up @@ -88,28 +91,23 @@ add_task(async function() {
browser.browsingContext.id,
"<browser> has the correct browsingContext"
);
is(
browser.browserId,
topContext.browserId,
"browsing context should have a correct <browser> id"
);

let id0 = await addFrame(browser, "frame0");
let browsingContext0 = getBrowsingContextById(id0);
isnot(browsingContext0, null);
is(browsingContext0.parent, topContext);

let id1 = await addFrame(browser, "frame1", "frame0");
let browsingContext1 = getBrowsingContextById(id1);
isnot(browsingContext1, null);
is(browsingContext1.parent, browsingContext0);

let id2 = await addFrame(browser, "frame2", "frame1");
let browsingContext2 = getBrowsingContextById(id2);
isnot(browsingContext2, null);
is(browsingContext2.parent, browsingContext1);

await removeFrame(browser, "frame2");
await removeFrame(browser, "frame0");

is(browsingContext1.children.indexOf(browsingContext2), -1);
is(topContext.children.indexOf(browsingContext0), -1);

// TODO(farre): Handle browsingContext removal [see Bug 1486719].
todo_isnot(browsingContext2.parent, browsingContext1);
todo_isnot(browsingContext0.parent, topContext);
});
});

Expand Down

0 comments on commit a7d4d40

Please sign in to comment.