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?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2997194-8--8_6_x.patch | 763 bytes | L-four |
| #5 | 2997194-5--8.5.x.patch | 735 bytes | ndf |
| #2 | 2997194-2.patch | 763 bytes | ndf |
Comments
Comment #2
ndf commentedAnd if it can be removed hereby the patch
Comment #4
ndf commentedFail 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.displacehas been committed!https://www.drupal.org/node/1847084
Comment #5
ndf commentedAttached file applies to drupal/core 8.5.x
Comment #7
ndf commentedComment #8
L-four commentedRan 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.
Comment #9
GrandmaGlassesRopeManI 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. 👍
Comment #12
lauriiiCommitted f054326 and pushed to 8.7.x. Also cherry-picked to 8.6.x. Thanks!