diff --git a/extensions/doPlugins_global.js b/extensions/doPlugins_global.js index ff6a26e1..5465c1fb 100644 --- a/extensions/doPlugins_global.js +++ b/extensions/doPlugins_global.js @@ -52,7 +52,7 @@ s._utils = { }, setSportDatencenter: function () { - if (window.document.domain.includes('sport.bild.de') || window.document.domain.includes('sportdaten.sportbild.bild.de')){ + if (window.location.hostname.includes('sport.bild.de') || window.location.hostname.includes('sportdaten.sportbild.bild.de')){ window.utag.data.page_document_type = window.location.pathname.includes('/liveticker/') ? 'live-sport' : 'sportdaten'; return window.utag.data.page_document_type; } @@ -178,7 +178,7 @@ s._articleViewTypeObj = { // Same domain check including subdomains. isFromInternal: function (referrer) { const referringDomain = s._utils.getDomainFromURLString(referrer); - const domain = window.document.domain; + const domain = window.location.hostname; const referringDomainSegments = referringDomain.split('.'); const documentDomainSegments = domain.split('.'); diff --git a/tests/doplugins/doplugins_article_view_type.test.js b/tests/doplugins/doplugins_article_view_type.test.js index 0f8b3cb9..23b42d6f 100644 --- a/tests/doplugins/doplugins_article_view_type.test.js +++ b/tests/doplugins/doplugins_article_view_type.test.js @@ -116,14 +116,14 @@ describe('articleViewType()', () => { it('should return TRUE if referring domain is from the same domain', function () { const anyDomain = 'any-domain.com'; - window.document.domain = anyDomain; + window.location.hostname = anyDomain; getDomainFromURLStringMock.mockReturnValue(anyDomain); const result = s._articleViewTypeObj.isFromInternal(anyReferrer); expect(result).toBe(true); }); it('should return FALSE if referring domain is NOT from the same domain', function () { - window.document.domain = 'any-domain.com'; + window.location.hostname = 'any-domain.com'; getDomainFromURLStringMock.mockReturnValue('any-other-domain.com'); const result = s._articleViewTypeObj.isFromInternal(anyReferrer); expect(result).toBe(false); @@ -131,7 +131,7 @@ describe('articleViewType()', () => { it('should return TRUE if referring domain is from sub domain', function () { const anyDomain = 'any-domain.com'; - window.document.domain = anyDomain; + window.location.hostname = anyDomain; getDomainFromURLStringMock.mockReturnValue(`any-sub-domain.${anyDomain}`); const result = s._articleViewTypeObj.isFromInternal(anyReferrer); expect(result).toBe(true); @@ -139,7 +139,7 @@ describe('articleViewType()', () => { it('should return TRUE if referring domain is from sub domain sportbild', function () { const anyDomain = 'sportbild.bild.de'; - window.document.domain = anyDomain; + window.location.hostname = anyDomain; getDomainFromURLStringMock.mockReturnValue(anyDomain); const result = s._articleViewTypeObj.isFromInternal(anyReferrer); expect(result).toBe(true); @@ -285,7 +285,7 @@ describe('articleViewType()', () => { const anyDomain = 'www.any-domain.de'; const referrer = `https://${anyDomain}`; cleanUpReferrerMock.mockReturnValue(referrer); - window.document.domain = anyDomain; + window.location.hostname = anyDomain; const result = s._articleViewTypeObj.isFromHome(referrer); expect(result).toBe(true); }); @@ -294,7 +294,7 @@ describe('articleViewType()', () => { const anyDomain = 'www.any-domain.de'; const referrer = `https://${anyDomain}/any-path`; cleanUpReferrerMock.mockReturnValue(referrer); - window.document.domain = anyDomain; + window.location.hostname = anyDomain; const result = s._articleViewTypeObj.isFromHome(referrer); expect(result).toBe(false); }); diff --git a/tests/doplugins/doplugins_bild_page_name.test.js b/tests/doplugins/doplugins_bild_page_name.test.js index ceb25bf9..14e5ac7a 100644 --- a/tests/doplugins/doplugins_bild_page_name.test.js +++ b/tests/doplugins/doplugins_bild_page_name.test.js @@ -107,19 +107,19 @@ describe('_bildPageNameObj', () => { describe('isSportDatencenterTyp', () => { it('should be false if Domain is not sport', () => { - window.document.domain = 'any-sport.domain.de'; + window.location.hostname = 'any-sport.domain.de'; const returnValue = s._bildPageNameObj.isSportDatencenterTyp(s); expect(returnValue).toBe(false); }); it('should be sportdaten if Domain is sport.bild.de', () => { - window.document.domain = 'sport.bild.de'; + window.location.hostname = 'sport.bild.de'; const returnValue = s._bildPageNameObj.isSportDatencenterTyp(s); expect(returnValue).toBe('sportdaten'); }); it('should be sportdaten if Domain is sportdaten.sportbild.bild.de', () => { - window.document.domain = 'sportdaten.sportbild.bild.de'; + window.location.hostname = 'sportdaten.sportbild.bild.de'; const returnValue = s._bildPageNameObj.isSportDatencenterTyp(s); expect(returnValue).toBe('sportdaten'); }); @@ -246,7 +246,7 @@ describe('_bildPageNameObj', () => { it('should set relevant data if isSportdatencentertyp live-sport is true', () => { window.utag.data.page_id = '12345678'; - window.document.domain = 'www.sport.bild.de'; + window.location.hostname = 'www.sport.bild.de'; window.location.pathname = 'any/path/liveticker/'; s._bildPageNameObj.setPageName(s); @@ -258,7 +258,7 @@ describe('_bildPageNameObj', () => { it('should set relevant data if isSportdatencentertyp sportdaten is true', () => { window.utag.data.page_id = '12345678'; - window.document.domain = 'www.sport.bild.de'; + window.location.hostname = 'www.sport.bild.de'; window.location.pathname = 'any/path/'; s._bildPageNameObj.setPageName(s); diff --git a/tests/mocks/browserMocks.js b/tests/mocks/browserMocks.js index 5a35efad..50c9fc9b 100644 --- a/tests/mocks/browserMocks.js +++ b/tests/mocks/browserMocks.js @@ -21,7 +21,8 @@ function createWindowMock() { referrer: '', domain: '', location: { - pathname: '' + pathname: '', + hostname: '' } }, navigator: { @@ -39,6 +40,7 @@ function createWindowMock() { hash: '', search: '', pathname: '', + hostname: '' } }; }