Skip to content

Commit a311f4a

Browse files
authored
Merge pull request #881 from Shopify/fix-firefox-test
Fix firefox testing
2 parents 5f56d3b + 63da54f commit a311f4a

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

src/iframe.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {addClassToElement, removeClassFromElement} from './utils/element-class';
66
const iframeStyles = {
77
width: '100%',
88
overflow: 'hidden',
9-
border: 'none',
9+
// Firefox for some reason sets 'border: medium' even if we set it to 'border: none'
10+
// when using JavaScript to set the style. The workaround is to set individual border styles
11+
'border-width': '0',
12+
'border-style': 'none',
1013
};
1114

1215
const iframeAttrs = {
@@ -91,6 +94,7 @@ export default class iframe {
9194
Object.keys(iframeStyles).forEach((key) => {
9295
this.el.style[key] = iframeStyles[key];
9396
});
97+
9498
Object.keys(iframeAttrs).forEach((key) => this.el.setAttribute(key, iframeAttrs[key]));
9599
this.el.setAttribute('name', config.name);
96100
this.styleTag = null;

test/unit/iframe.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ describe('Iframe class', () => {
117117
assert.calledWith(setWidthStub, constructorConfig.width);
118118
});
119119

120-
it('sets width to 100%, overflow to hidden, and border to none in iframe\'s style', () => {
120+
it('sets width to 100%, overflow to hidden, borderWidth to 0px and borderStyle to none in iframe\'s style', () => {
121121
iframe = new Iframe(parent, constructorConfig);
122122
assert.equal(iframe.el.style.width, '100%');
123123
assert.equal(iframe.el.style.overflow, 'hidden');
124-
assert.include(iframe.el.style.border, 'none');
124+
assert.include(iframe.el.style.borderStyle, 'none');
125+
assert.include(iframe.el.style.borderWidth, '0px');
125126
});
126127

127128
it('disables scrolling, allows transparency, and removes border in iframe\'s attributes', () => {
@@ -507,4 +508,4 @@ describe('Iframe class', () => {
507508
});
508509
});
509510
});
510-
});
511+
});

testem-ci.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"Chrome"
44
],
55
"launch_in_ci": [
6-
"Chrome"
6+
"Chrome",
7+
"Firefox"
78
],
89
"framework": "mocha",
910
"src_files": "test/build/test.js"

testem.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"Chrome"
44
],
55
"launch_in_ci": [
6-
"Chrome"
6+
"Chrome",
7+
"Firefox"
78
],
89
"framework": "mocha",
910
"src_files": "test/build/test.js"

0 commit comments

Comments
 (0)