Skip to content

Commit 72c9909

Browse files
committed
Emoji: Suppress console errors from sessionStorage usage in sandboxed post embed iframe.
Amends [56074]. Props westonruter, flixos90. Fixes #58978. See #58472. git-svn-id: https://develop.svn.wordpress.org/trunk@56358 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4709117 commit 72c9909

1 file changed

Lines changed: 25 additions & 32 deletions

File tree

src/js/_enqueues/lib/emoji-loader.js

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,20 @@
7373
* @returns {?SupportTests} Support tests, or null if not set or older than 1 week.
7474
*/
7575
function getSessionSupportTests() {
76-
if (
77-
typeof sessionStorage !== 'undefined' &&
78-
sessionStorageKey in sessionStorage
79-
) {
80-
try {
81-
/** @type {SessionSupportTests} */
82-
var item = JSON.parse(
83-
sessionStorage.getItem( sessionStorageKey )
84-
);
85-
if (
86-
typeof item === 'object' &&
87-
typeof item.timestamp === 'number' &&
88-
new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds.
89-
typeof item.supportTests === 'object'
90-
) {
91-
return item.supportTests;
92-
}
93-
} catch ( e ) {}
94-
}
76+
try {
77+
/** @type {SessionSupportTests} */
78+
var item = JSON.parse(
79+
sessionStorage.getItem( sessionStorageKey )
80+
);
81+
if (
82+
typeof item === 'object' &&
83+
typeof item.timestamp === 'number' &&
84+
new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds.
85+
typeof item.supportTests === 'object'
86+
) {
87+
return item.supportTests;
88+
}
89+
} catch ( e ) {}
9590
return null;
9691
}
9792

@@ -105,20 +100,18 @@
105100
* @param {SupportTests} supportTests Support tests.
106101
*/
107102
function setSessionSupportTests( supportTests ) {
108-
if ( typeof sessionStorage !== 'undefined' ) {
109-
try {
110-
/** @type {SessionSupportTests} */
111-
var item = {
112-
supportTests: supportTests,
113-
timestamp: new Date().valueOf()
114-
};
103+
try {
104+
/** @type {SessionSupportTests} */
105+
var item = {
106+
supportTests: supportTests,
107+
timestamp: new Date().valueOf()
108+
};
115109

116-
sessionStorage.setItem(
117-
sessionStorageKey,
118-
JSON.stringify( item )
119-
);
120-
} catch ( e ) {}
121-
}
110+
sessionStorage.setItem(
111+
sessionStorageKey,
112+
JSON.stringify( item )
113+
);
114+
} catch ( e ) {}
122115
}
123116

124117
/**

0 commit comments

Comments
 (0)