Skip to content

Commit

Permalink
using internal methods for loading external scripts in medianetRtdPro…
Browse files Browse the repository at this point in the history
…vider (#8506)

Co-authored-by: monis.q <monis.q@media.net>
  • Loading branch information
monis0395 and monisq authored Jun 1, 2022
1 parent fffd1f3 commit 611338b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 4 additions & 6 deletions modules/medianetRtdProvider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {insertElement, isEmptyStr, isFn, isStr, logError, mergeDeep} from '../src/utils.js';
import {isEmptyStr, isFn, isStr, logError, mergeDeep} from '../src/utils.js';
import {loadExternalScript} from '../src/adloader.js';
import {submodule} from '../src/hook.js';
import {getGlobal} from '../src/prebidGlobal.js';
import {includes} from '../src/polyfill.js';
Expand Down Expand Up @@ -82,11 +83,8 @@ function executeCommand(command) {
}

function loadRtdScript(customerId) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = getClientUrl(customerId, window.location.hostname);
insertElement(script, window.document, 'head');
const url = getClientUrl(customerId, window.location.hostname);
loadExternalScript(url, MODULE_NAME)
}

function getAdUnits(adUnits, adUnitCodes) {
Expand Down
3 changes: 2 additions & 1 deletion src/adloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const _approvedLoadExternalJSList = [
'akamaidap',
'ftrackId',
'inskin',
'hadron'
'hadron',
'medianet'
]

/**
Expand Down
4 changes: 0 additions & 4 deletions test/spec/modules/medianetRtdProvider_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as medianetRTD from '../../../modules/medianetRtdProvider.js';
import * as sinon from 'sinon';
import { assert } from 'chai';
import * as utils from '../../../src/utils.js';

let sandbox;
let setDataSpy;
Expand All @@ -20,9 +19,6 @@ const conf = {
describe('medianet realtime module', function () {
beforeEach(function () {
sandbox = sinon.sandbox.create();
const insertStub = sandbox.stub(utils, 'insertElement')
insertStub.withArgs(sinon.match.any, sinon.match.any, 'head')
.returns(() => void 0)
window.mnjs = window.mnjs || {};
window.mnjs.que = window.mnjs.que || [];
window.mnjs.setData = setDataSpy = sandbox.spy();
Expand Down

0 comments on commit 611338b

Please sign in to comment.