Skip to content

Commit d69c982

Browse files
jarnixjsnellbaker
authored andcommitted
bugfix for Firefox for some ads that use document.write (prebid#3524)
* bugfix for Firefox for some ads that use document.write * testing that the doc.open method is called..... * added a sinon.spy() for the doc.open method
1 parent 9b08b15 commit d69c982

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/prebid.js

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
326326
const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`;
327327
emitAdRenderFail(PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid);
328328
} else if (ad) {
329+
doc.open('text/html', 'replace');
329330
doc.write(ad);
330331
doc.close();
331332
setRenderSize(doc, width, height);

test/spec/unit/pbjs_api_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ describe('Unit: Prebid Module', function () {
990990

991991
beforeEach(function () {
992992
doc = {
993+
open: sinon.spy(),
993994
write: sinon.spy(),
994995
close: sinon.spy(),
995996
defaultView: {
@@ -1040,6 +1041,7 @@ describe('Unit: Prebid Module', function () {
10401041
});
10411042
adResponse.ad = "<script type='text/javascript' src='http://server.example.com/ad/ad.js'></script>";
10421043
$$PREBID_GLOBAL$$.renderAd(doc, bidId);
1044+
assert.ok(doc.open, 'open method called');
10431045
assert.ok(doc.write.calledWith(adResponse.ad), 'ad was written to doc');
10441046
assert.ok(doc.close.called, 'close method called');
10451047
});

0 commit comments

Comments
 (0)