We have an end-2-end test-suite running with Cypress.io (https://www.cypress.io/)
All pages that have tableheader.js included fail. One of those page is /admin/content so obviously this makes it hard to test the Drupal admin backend.

The error is Uncaught TypeError: Cannot read property 'displace' of undefined
on last line in tableheader.js

(function ($, Drupal, displace) {

   ...

})(jQuery, Drupal, window.parent.Drupal.displace);

Actually window.parent is the first undefined object here.

The reason is:
1. Cypress.io is running the test-suite in a browser.
2. It includes the Drupal website inside an iframe and starts interacting with it (that how Cypress.io works).
3. Now window.parent.Drupal.displace tries to interact with 1. the parent of the iframe. But this is forbidden due to XSS-prevention on browser level.

When reading javascript / browser documentation I read that window.parent refers to the enclosing page if the script is running in an iframe. Otherwise window.parent refers to the page itself. See https://developer.mozilla.org/en-US/docs/Web/API/Window/parent

When I replace window.parent.Drupal.displace with window.Drupal.displace my problems are fixed.

I cannot think about a use case where Drupal renders an iframe with a tableheader inside it.
So I wonder why we have window.parent in place now?

CommentFileSizeAuthor
#8 2997194-8--8_6_x.patch763 bytesL-four
#5 2997194-5--8.5.x.patch735 bytesndf
#2 2997194-2.patch763 bytesndf

Comments

ndf created an issue. See original summary.

ndf’s picture

Version: 8.5.6 » 8.7.x-dev
Status: Active » Needs review
StatusFileSize
new763 bytes

And if it can be removed hereby the patch

Status: Needs review » Needs work

The last submitted patch, 2: 2997194-2.patch, failed testing. View results

ndf’s picture

Status: Needs work » Needs review

Fail is because I files the issue on 8.5.6 (where I found it), but the patch is for 8.7.x

And this is the issue where window.parent.Drupal.displace has been committed!
https://www.drupal.org/node/1847084

ndf’s picture

StatusFileSize
new735 bytes

Attached file applies to drupal/core 8.5.x

Status: Needs review » Needs work

The last submitted patch, 5: 2997194-5--8.5.x.patch, failed testing. View results

ndf’s picture

Status: Needs work » Needs review
L-four’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new763 bytes

Ran into the same issue with drupal and cypress. 2997194-5--8.5.x.patch fixed the issue for me.

It doesn't apply on 7.6.x created a new patch for 7.6.x.

GrandmaGlassesRopeMan’s picture

Title: tableheader.js throws error when running Drupal inside iframe » tableheader.js throws error when running Drupal inside an iframe
Issue tags: +JavaScript

I wanted to figure out why this was the way it is.

It looks like in #1847084: Measure/track displacing elements better + provide change events for them (fix overlay + toolbar), when parts of the admin ui could still be rendered in an overlay, rip #2088121: Remove Overlay, we needed to fetch the parents displacement values.

Since that doesn't happen anymore, I think changing this makes sense. 👍

  • lauriii committed f054326 on 8.7.x
    Issue #2997194 by ndf, L-four, drpal: tableheader.js throws error when...

  • lauriii committed 803c6ed on 8.6.x
    Issue #2997194 by ndf, L-four, drpal: tableheader.js throws error when...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed f054326 and pushed to 8.7.x. Also cherry-picked to 8.6.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.