Make WordPress Core

Opened 2 weeks ago

Last modified 2 weeks ago

#44306 new defect (bug)

wp-embed-template.js Sends a message earlier than the wp-embed.js listener will be installed

Reported by: Cawa-93 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 4.9.6
Component: Embeds Keywords:
Focuses: javascript Cc:


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"}

Change History (1)

#1 @Cawa-93
2 weeks ago

If, however, I pre-register the script in the header and not in the footer, then the frame of the widget is displayed correctly.

function embed_on_head() {
        wp_enqueue_script('wp-embed', includes_url( '/js/wp-embed.min.js' ), array(), false, false);

Here is the log:

14:52:18.132 wp-embed.js?ver=4.9.6:121 addEventListener(message)
14:52:19.536 (index):758 sendEmbedMessage(height, 299)
14:52:19.574 wp-embed.js?ver=4.9.6:31  receiveEmbedMessage data: {message: "height", value: 299, secret: "Fr0AAXkEeU"}
14:52:21.533 wp-embed.js?ver=4.9.6:89 onLoad()
14:52:22.409 (index):758 sendEmbedMessage(height, 299)
14:52:22.510 wp-embed.js?ver=4.9.6:31  receiveEmbedMessage data: {message: "height", value: 299, secret: "Fr0AAXkEeU"}
14:52:23.259 wp-embed.js?ver=4.9.6:89 onLoad()
Last edited 2 weeks ago by Cawa-93 (previous) (diff)
Note: See TracTickets for help on using tickets.