salesforce.js (1514B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Bug 1855139 - The pop-up for "Où trouver ma référence ?" option is blank at 9 * garantie30minutes.sncf.com with ETP set to STANDARD 10 * 11 * emeraude.my.salesforce.com is marked as a tracker, and it tries to access localstorage, but the 12 * script returned does not handle the error. The shim replaces localstorage with a fake 13 * interface to avoid the error. 14 * 15 */ 16 17 /* globals cloneInto */ 18 19 (function () { 20 const win = window.wrappedJSObject; 21 22 try { 23 // We only replace the indexedDB when emeraude.my.salesforce.com is loaded in a 24 // third-party context. Note that this is not strictly correct because 25 // this is a cross-origin check but not a third-party check. 26 if (win.parent == win || win.location.origin == win.top.location.origin) { 27 return; 28 } 29 } catch (e) { 30 // If we get a security error when accessing the top-level origin, this 31 // shows that the window is in a cross-origin context. In this case, we can 32 // proceed to apply the shim. 33 if (e.name != "SecurityError") { 34 throw e; 35 } 36 } 37 38 const emptyMsg = cloneInto({ message: "" }, window); 39 40 const idb = { 41 open: () => win.Promise.reject(emptyMsg), 42 }; 43 44 Object.defineProperty(win, "indexedDB", { 45 value: cloneInto(idb, window, { cloneFunctions: true }), 46 }); 47 })();