iframe 'src' attribute is not set when the setAttribute method is triggered with an Escape key
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
People
(Reporter: naid, Unassigned)
References
()
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Steps to reproduce:
use this html code:
<iframe id="foo" width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=-157.89748191833496%2C21.279137394108723%2C-157.82581329345706%2C21.315123560738826&layer=mapnik"></iframe>
<script>
document.addEventListener('keydown', event => {
if (event.key === 'Escape' || event.key === 'Enter') {
const foo = document.querySelector('#foo')
foo.setAttribute('src', foo.getAttribute('src'))
console.log('boom')
}
})
</script>
- click on the whitespace somewhere on the page (so that the keypress is not captured by the iframe)
- press 'Escape'
Actual results:
iframe does not get reloaded
Expected results:
The iframe should get reloaded. Like it does when other action triggers this, for example an 'Enter' key press.
This seems to be specific to the 'Escape' key.
It can also be seen that the setAttribute metod gets reached, since the 'console log' a line bellow runs no problem.
I have also tried with different iframes, like youtube embeds for example, but it is the same thing.
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•3 years ago
|
||
I can reproduce this only when the testcase is in the parent document:
https://jsfiddle.net/d_toybox/myv1but8/show/
But I cannot reproduce it if it's in a child and the iframe is not OOP.
https://jsfiddle.net/d_toybox/myv1but8/
Perhaps, the Escape
key stops the new loading. But I have no idea why it does not work in iframe.
Thank you for taking the time to look into it.
However, for me, it is not the case what you suggest. I can reproduce it in both cases in the same way.
I just have to make sure I click on the whitespace (empty space around the map embed) before pressing a key, to make sure that the keypress is captured by the script, and is not captured by it parent (the jsfiddle editor) or the child embed (map).
Description
•