mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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
This commit is contained in:
parent
470911715d
commit
72c9909999
@ -73,25 +73,20 @@
|
||||
* @returns {?SupportTests} Support tests, or null if not set or older than 1 week.
|
||||
*/
|
||||
function getSessionSupportTests() {
|
||||
if (
|
||||
typeof sessionStorage !== 'undefined' &&
|
||||
sessionStorageKey in sessionStorage
|
||||
) {
|
||||
try {
|
||||
/** @type {SessionSupportTests} */
|
||||
var item = JSON.parse(
|
||||
sessionStorage.getItem( sessionStorageKey )
|
||||
);
|
||||
if (
|
||||
typeof item === 'object' &&
|
||||
typeof item.timestamp === 'number' &&
|
||||
new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds.
|
||||
typeof item.supportTests === 'object'
|
||||
) {
|
||||
return item.supportTests;
|
||||
}
|
||||
} catch ( e ) {}
|
||||
}
|
||||
try {
|
||||
/** @type {SessionSupportTests} */
|
||||
var item = JSON.parse(
|
||||
sessionStorage.getItem( sessionStorageKey )
|
||||
);
|
||||
if (
|
||||
typeof item === 'object' &&
|
||||
typeof item.timestamp === 'number' &&
|
||||
new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds.
|
||||
typeof item.supportTests === 'object'
|
||||
) {
|
||||
return item.supportTests;
|
||||
}
|
||||
} catch ( e ) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -105,20 +100,18 @@
|
||||
* @param {SupportTests} supportTests Support tests.
|
||||
*/
|
||||
function setSessionSupportTests( supportTests ) {
|
||||
if ( typeof sessionStorage !== 'undefined' ) {
|
||||
try {
|
||||
/** @type {SessionSupportTests} */
|
||||
var item = {
|
||||
supportTests: supportTests,
|
||||
timestamp: new Date().valueOf()
|
||||
};
|
||||
try {
|
||||
/** @type {SessionSupportTests} */
|
||||
var item = {
|
||||
supportTests: supportTests,
|
||||
timestamp: new Date().valueOf()
|
||||
};
|
||||
|
||||
sessionStorage.setItem(
|
||||
sessionStorageKey,
|
||||
JSON.stringify( item )
|
||||
);
|
||||
} catch ( e ) {}
|
||||
}
|
||||
sessionStorage.setItem(
|
||||
sessionStorageKey,
|
||||
JSON.stringify( item )
|
||||
);
|
||||
} catch ( e ) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user