Skip to content

Commit

Permalink
Merge pull request #881 from Shopify/fix-firefox-test
Browse files Browse the repository at this point in the history
Fix firefox testing
  • Loading branch information
madmath authored Jan 29, 2025
2 parents 5f56d3b + 63da54f commit a311f4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {addClassToElement, removeClassFromElement} from './utils/element-class';
const iframeStyles = {
width: '100%',
overflow: 'hidden',
border: 'none',
// Firefox for some reason sets 'border: medium' even if we set it to 'border: none'
// when using JavaScript to set the style. The workaround is to set individual border styles
'border-width': '0',
'border-style': 'none',
};

const iframeAttrs = {
Expand Down Expand Up @@ -91,6 +94,7 @@ export default class iframe {
Object.keys(iframeStyles).forEach((key) => {
this.el.style[key] = iframeStyles[key];
});

Object.keys(iframeAttrs).forEach((key) => this.el.setAttribute(key, iframeAttrs[key]));
this.el.setAttribute('name', config.name);
this.styleTag = null;
Expand Down
7 changes: 4 additions & 3 deletions test/unit/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ describe('Iframe class', () => {
assert.calledWith(setWidthStub, constructorConfig.width);
});

it('sets width to 100%, overflow to hidden, and border to none in iframe\'s style', () => {
it('sets width to 100%, overflow to hidden, borderWidth to 0px and borderStyle to none in iframe\'s style', () => {
iframe = new Iframe(parent, constructorConfig);
assert.equal(iframe.el.style.width, '100%');
assert.equal(iframe.el.style.overflow, 'hidden');
assert.include(iframe.el.style.border, 'none');
assert.include(iframe.el.style.borderStyle, 'none');
assert.include(iframe.el.style.borderWidth, '0px');
});

it('disables scrolling, allows transparency, and removes border in iframe\'s attributes', () => {
Expand Down Expand Up @@ -507,4 +508,4 @@ describe('Iframe class', () => {
});
});
});
});
});
3 changes: 2 additions & 1 deletion testem-ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"Chrome"
],
"launch_in_ci": [
"Chrome"
"Chrome",
"Firefox"
],
"framework": "mocha",
"src_files": "test/build/test.js"
Expand Down
3 changes: 2 additions & 1 deletion testem.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"Chrome"
],
"launch_in_ci": [
"Chrome"
"Chrome",
"Firefox"
],
"framework": "mocha",
"src_files": "test/build/test.js"
Expand Down

0 comments on commit a311f4a

Please sign in to comment.