diff --git a/firefox-ios/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentEnd/Ads.js b/firefox-ios/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentEnd/Ads.js index 269d07410dd5e..7335085e842f0 100644 --- a/firefox-ios/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentEnd/Ads.js +++ b/firefox-ios/Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentEnd/Ads.js @@ -5,15 +5,13 @@ /** * Send * - current URL - * - cookies of this page * - all links found in this page * to the native application. */ function sendCurrentState() { let message = { 'url': document.location.href, - 'urls': getLinks(), - 'cookies': getCookies() + 'urls': getLinks() }; webkit.messageHandlers.adsMessageHandler.postMessage(message); @@ -38,56 +36,6 @@ function getLinks() { return urls; } -/** - * Get all cookies for the current document. - * - * @return {Array<{name: string, value: string}>} containing all cookies. - */ -function getCookies() { - let cookiesList = safeCookiesList(); - let result = []; - - cookiesList.forEach(cookie => { - var [name, ...value] = cookie.split('='); - // For that special cases where the value contains '='. - value = value.join("=") - - result.push({ - "name" : name, - "value" : value - }); - }); - - return result; -} - -// FXIOS-13891: WebKit process crashes on cross-origin cookie operation on about:blank tabs -// Helper method to verify via SecurityError earlier than touching the document crashes it -function safeCookiesList() { - let documentCookies = []; - - const isNewTab = window.location.protocol == "about:"; - const hasOpener = !!window.opener; - const hasParent = hasOpener && window.opener.parent != window.opener; - - // Special-casing only different origins coming from different frames in new tabs - if (isNewTab && hasOpener && hasParent) { - const frameParent = window.opener.parent; - // Positively catch the SecurityError on the conditional as a way to not touch the cookie inside - try { - if (frameParent.location.origin == window.opener.location.origin) { - documentCookies = document.cookie.split("; "); - } - } catch { - documentCookies = [""]; - } - } else { - documentCookies = document.cookie.split("; "); - } - - return documentCookies; -} - // Whenever a page is first accessed or when loaded from cache // send all needed data about the ads provider to the app. const events = ["pageshow", "load"]; diff --git a/focus-ios/Blockzilla/Ads.js b/focus-ios/Blockzilla/Ads.js index 911f69e8c4d17..10c89144b0a0d 100644 --- a/focus-ios/Blockzilla/Ads.js +++ b/focus-ios/Blockzilla/Ads.js @@ -8,15 +8,13 @@ /** * Send * - current URL - * - cookies of this page * - all links found in this page * to the native application. */ function sendCurrentState() { let message = { 'url': document.location.href, - 'urls': getLinks(), - 'cookies': getCookies() + 'urls': getLinks() }; webkit.messageHandlers.adsMessageHandler.postMessage(message); @@ -41,29 +39,6 @@ function getLinks() { return urls; } -/** - * Get all cookies for the current document. - * - * @return {Array<{name: string, value: string}>} containing all cookies. - */ -function getCookies() { - let cookiesList = document.cookie.split("; "); - let result = []; - - cookiesList.forEach(cookie => { - var [name, ...value] = cookie.split('='); - // For that special cases where the value contains '='. - value = value.join("=") - - result.push({ - "name" : name, - "value" : value - }); - }); - - return result; -} - // Whenever a page is first accessed or when loaded from cache // send all needed data about the ads provider to the app. const events = ["pageshow", "load"];