Skip to content
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

Fix #3939 - update firefox specific code in renderAd function #3980

Merged
merged 2 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,16 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`;
emitAdRenderFail(PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid);
} else if (ad) {
doc.open('text/html', 'replace');
// will check if browser is firefox and below version 67, if so execute special doc.open()
// for details see: https://github.com/prebid/Prebid.js/pull/3524
// TODO remove this browser specific code at later date (when Firefox < 67 usage is mostly gone)
if (navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox/') > -1) {
const firefoxVerRegx = /firefox\/([\d\.]+)/;
let firefoxVer = navigator.userAgent.toLowerCase().match(firefoxVerRegx)[1]; // grabs the text in the 1st matching group
if (firefoxVer && parseInt(firefoxVer, 10) < 67) {
doc.open('text/html', 'replace');
}
}
doc.write(ad);
doc.close();
setRenderSize(doc, width, height);
Expand Down
2 changes: 0 additions & 2 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,6 @@ describe('Unit: Prebid Module', function () {

beforeEach(function () {
doc = {
open: sinon.spy(),
write: sinon.spy(),
close: sinon.spy(),
defaultView: {
Expand Down Expand Up @@ -1041,7 +1040,6 @@ describe('Unit: Prebid Module', function () {
});
adResponse.ad = "<script type='text/javascript' src='http://server.example.com/ad/ad.js'></script>";
$$PREBID_GLOBAL$$.renderAd(doc, bidId);
assert.ok(doc.open, 'open method called');
assert.ok(doc.write.calledWith(adResponse.ad), 'ad was written to doc');
assert.ok(doc.close.called, 'close method called');
});
Expand Down