In Firefox, when you create an iframe it starts loading about:blank
. Then your script races with that load: you modify the DOM, and then about:blank loads and wipes out your changes.
"The spec" doesn't define the behavior here so far (like most of document loading), though there's a proposal in webapps that would do so. That proposal would be that there should be no about:blank load in this situation and instead a fake load event should get fired even though no load happened (because websites depend on frames with no src firing load events).