-
Notifications
You must be signed in to change notification settings - Fork 20.6k
CSS: Fix support test results for initially hidden iframes #5317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. We will need a unit test added for a change like that. This one would go to https://github.com/jquery/jquery/blob/main/test/unit/css.js.
Thanks, @mgol. I added a test and verified that it failed prior to my change. |
src/css/support.js
Outdated
@@ -18,6 +18,11 @@ define( [ | |||
return; | |||
} | |||
|
|||
// Don't run until window is visible (https://github.com/jquery/jquery-ui/issues/2176) | |||
if ( documentElement.offsetHeight === 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be true if height: 0
is set on the root element in CSS. We may need a better check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any suggestions? I'm not sure what the rational for setting height: 0
on the root element would be.
Maybe I can have it check if the width is zero too. I didn't test that yet. I wanted to get your thoughts on that first.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather check against div
directly than against its containing document and assuming accuracy and correspondence. Specifically, I think div.offsetWidth
would be a good target: https://jsfiddle.net/tjnvs51o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated to div.offsetWidth
. It think it works, though I'm struggling to figure out how to run all the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple ways to run tests:
- With npm scripts:
npm run browser
. This will run tests on the command line using karma and headless browsers. Set the browser you want with theBROWSERS
env var. See Gruntfile.cjs. - Open the QUnit test page directly and run the test using the QUnit UI. Run
node test/server.js
and visit http://localhost:3000/test/. Your test is in thesupport
module so select that from the module list to filter the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test in this PR is failing in Safari. Also, we want to remove the test container
element before the early return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil we should document this in README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning on documenting all of the upcoming test changes (to drop grunt, karma, etc). node test/server.js
will likely be added to an npm script.
test/unit/css.js
Outdated
"css/cssComputeStyleTests.html", | ||
function( assert, jQuery, window, document, initialHeight ) { | ||
assert.expect( 2 ); | ||
assert.strictEqual( initialHeight, 0, "initial height should be undefined" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Safari actually is reporting offsetHeight for the div in the hidden iframe: https://github.com/jquery/jquery/actions/runs/6634909917/job/18189746921?pr=5317#step:9:161
assert.strictEqual( initialHeight, 0, "initial height should be undefined" ); | |
assert.strictEqual( initialHeight === 0 ? 20 : initialHeight, 20, | |
"hidden-frame content sizes should be zero or accurate" ); |
I made the suggested updates. I haven't really been able to get the tests running well. I might be running them wrong. The way I'm running them, it's failing on |
@ssigwart you need to rebase over latest |
Thanks, @mgol. I'll try to do that tonight. I try not to rebase after people have started reviewing so it doesn't mess up their review. |
Also, there’s a bug in Chrome 117 & 118 that causes one support test failure. The issue is fixed in Chrome 119 so we’re just waiting for GitHub Actions images to be updated with Chrome 119 to resolve this one failure. |
If the iframe is not initially visible, `boxSizingReliableVal` gets set to false, which triggers this code to set the wrong dialog width here: https://github.com/jquery/jquery/blob/a7cc3a0f0418d168ff3818576161c5af24d0ca78/src/css.js#L418-L426 I think this should solve jquery/jquery-ui#2176.
5104a29
to
8edeb51
Compare
Thanks. I rebased and force pushed that. Running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates! LGTM.
Thanks for your help and merging this. |
Also, account for the fact old Firefox (<61) has `null` computed style for elements in such iframes. Ref jquerygh-5317
Also, account for the fact old Firefox (<61) has `null` computed style for elements in such iframes. Ref jquerygh-5317
I submitted two followups to this PR, to apply the fix to the |
Summary
If the iframe is not initially visible,
boxSizingReliableVal
gets set to false, which triggers this code to set the wrong dialog width here:jquery/src/css.js
Lines 418 to 426 in a7cc3a0
I think this should solve jquery/jquery-ui#2176.
You can reproduce something similar to the original issue by creating the following two files in the top level of a website. Then go to
index.html
, click "Show Frame", then "Show Popup". The popup should be 600px, but is not.index.html
innerIframe.html
Checklist