-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
If you create a frame without specifying a src attribute, the spec says that the frame is created with a URL of about:blank:
If, when the element is created, the srcdoc attribute is not set, and the src attribute is either also not set or set but its value cannot be resolved, the browsing context will remain at the initial about:blank page.
The spec doesn't seem to say that that about:blank is special in any way, but it seems like no two browsers treat it alike. Here's an experiment.
I've provided a test page at http://avidrissman.github.io/htmltests/aboutblank.html. It has an iframe with no specified src, and two buttons. One button loads a page into the frame, and one button adds an entry to the session history with pushState.
Scenarios:
- Go to the test page. Click the "Load the frame" button. When the frame is loaded, is a new entry added to the session history?
- Go to the test page. Click the "Push a history entry" button, then click the "Load the frame" button. When the frame is loaded, is a new entry added to the session history?
- Set up as in scenario 2. If the browser created a new entry, what happens to the iframe when you go back once?
- Set up as in scenario 2. What happens to the iframe when you go back to the initial test page (in one jump)?
The results that I'm seeing vary wildly:
| Chrome | Edge | Safari | Firefox | |
|---|---|---|---|---|
| Scenario 1 | No entry is added. | No entry is added. | No entry is added. | Yes, an entry is added. |
| Scenario 2 | No entry is added. | No entry is added. | Yes, an entry is added. | Yes, an entry is added. |
| Scenario 3 | n/a | n/a | The iframe clears. | The iframe clears. |
| Scenario 4 | The iframe keeps its content. | The iframe keeps its content. | The iframe clears. | The iframe keeps its content. |
(As a note, I don't have access to Edge myself, so I asked a colleague to perform this test. Apologies if I got the results wrong.)
Chrome/Edge: These browsers seem to have the rule that if an iframe starts with no src, and gets one later, then the initial about:blank goes away. This might be good in terms of not creating confusing extra entries in the session history. However, this creates a situation where going back over a pushState doesn't return you to the page you saw. Before the pushState, you were looking at an empty frame. Shouldn't going back return you to that empty frame?
Safari: This browser sometimes creates a new session history entry when loading a blank iframe. I'm not sure what rule it's following; this behavior might be accidental.
Firefox: This browser seems to have the rule that loading an iframe always creates a new session history entry. It is consistent with that, though its failure to clear the iframe when jumping back two page appears to be a bug.
In any case, though, it looks like this is a case where no two browsers agree on what should be done. Can we decide what the rule for about:blank elision is?