Skip to content

Commit eb33b59

Browse files
authored
Keep existing allowed permissions in appended iframes (#134)
1 parent 2a279ad commit eb33b59

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/wombat.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,9 @@ Wombat.prototype.rewriteNodeFuncArgs = function(
16551655
}
16561656
var created = originalFn.call(fnThis, newNode, oldNode);
16571657
if (created && created.tagName === 'IFRAME') {
1658-
created.allow = 'autoplay \'self\'; fullscreen \'self\'';
1658+
const currentAllow = created.allow ? `; ${created.allow}` : '';
1659+
created.allow = `autoplay 'self'; fullscreen 'self'${currentAllow}`;
1660+
16591661
this.initIframeWombat(created);
16601662
}
16611663
return created;

test/overrides-dom.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,15 @@ test('Node.appendChild: should rewrite a element with multiple children are supp
836836
const a1 = window.WombatTestUtil.createUntamperedWithElement('a');
837837
const a2 = window.WombatTestUtil.createUntamperedWithElement('a');
838838
const a3 = window.WombatTestUtil.createUntamperedWithElement('a');
839+
const iframe = window.WombatTestUtil.createUntamperedWithElement('iframe');
839840
a1.href = 'http://example1.com';
840841
a2.href = 'http://example2.com';
841842
a3.href = 'http://example3.com';
843+
iframe.allow = 'fullscreen; clipboard-write';
842844
div.appendChild(a2);
843845
div.appendChild(a3);
844846
div.appendChild(a1);
847+
div.appendChild(iframe);
845848
return {
846849
a1: window.WombatTestUtil.getElementPropertyAsIs(a1, 'href').endsWith(
847850
'mp_/http://example1.com'
@@ -851,10 +854,12 @@ test('Node.appendChild: should rewrite a element with multiple children are supp
851854
),
852855
a3: window.WombatTestUtil.getElementPropertyAsIs(a3, 'href').endsWith(
853856
'mp_/http://example3.com'
854-
)
857+
),
858+
iframe: window.WombatTestUtil.getElementPropertyAsIs(iframe, 'allow')
859+
=== 'autoplay \'self\'; fullscreen \'self\'; fullscreen; clipboard-write',
855860
};
856861
});
857-
t.deepEqual(result, { a1: true, a2: true, a3: true });
862+
t.deepEqual(result, { a1: true, a2: true, a3: true, iframe: true });
858863
});
859864

860865
test('Node.insertBefore: should rewrite a element with no children are supplied', async t => {

0 commit comments

Comments
 (0)