#44306 closed defect (bug) (fixed)
wp-embed-template.js Sends a message earlier than the wp-embed.js listener will be installed
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Embeds | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
I use google chrome v67.0.3396.62
In the content of the page is inserted a link to another page of the same site.
This link is replaced by the iframe.
However, this frame is loaded before downloading the listener's wp-embed. Because of this, the frame does not update its height and does not replace the blockquote element
I enabled debugging and added the output to the console to monitor the execution order. Here is the result:
14:36:01.651 (index):758 sendEmbedMessage(height, 348) 14:36:02.134 wp-embed.js?ver=4.9.6:121 addEventListener(message) 14:36:02.588 wp-embed.js?ver=4.9.6:89 onLoad() 14:36:04.889 wp-embed.js?ver=4.9.6:89 onLoad()
The widget only appears if you resize the page after loading the page. Here is the log
14:36:08.091 (index):758 sendEmbedMessage(height, 250) 14:36:08.092 wp-embed.js?ver=4.9.6:31 receiveEmbedMessage data: {message: "height", value: 250, secret: "Fr0AAXkEeU"} 14:36:08.240 (index):758 sendEmbedMessage(height, 250) 14:36:08.240 wp-embed.js?ver=4.9.6:31 receiveEmbedMessage data: {message: "height", value: 250, secret: "Fr0AAXkEeU"}
Attachments (1)
Change History (9)
#2
@
3 years ago
While I haven't seen this issue myself, I have solution that should prevent the issue from happening.
#3
@
3 years ago
- Milestone changed from Awaiting Review to Future Release
- Severity changed from major to normal
Copying over from #44632:
To solve the race condition, I think wp-embed-template.js
should
- not send the message on load if the secret is missing
- send the message as soon as the secret has been added (which means
wp-embed.js
has been loaded)
@
3 years ago
Demonstration showing how a slow-loading wp-embed.js can cause post embeds to fail to get sized
#4
@
3 years ago
- Milestone changed from Future Release to 5.9
- Owner set to westonruter
- Status changed from new to accepted
- Version changed from 4.9.6 to 4.4
#5
@
3 years ago
I have the fix for this included in the pull request for #44632: https://github.com/WordPress/wordpress-develop/pull/1745
If, however, I pre-register the script in the header and not in the footer, then the frame of the widget is displayed correctly.
Here is the log: