Make WordPress Core

Changeset 56364


Ignore:
Timestamp:
08/07/2023 04:52:56 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Emoji: Suppress console errors from sessionStorage usage in sandboxed post embed iframe.

Amends [56074].

Props westonruter, flixos90.
Reviewed by westonruter, SergeyBiryukov.
Merges [56358] to the 6.3 branch.
Fixes #58978. See #58472.

Location:
branches/6.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.3

  • branches/6.3/src/js/_enqueues/lib/emoji-loader.js

    r56119 r56364  
    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        }
     
    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                                 };
    115 
    116                                 sessionStorage.setItem(
    117                                         sessionStorageKey,
    118                                         JSON.stringify( item )
    119                                 );
    120                         } catch ( e ) {}
    121                 }
     103                try {
     104                        /** @type {SessionSupportTests} */
     105                        var item = {
     106                                supportTests: supportTests,
     107                                timestamp: new Date().valueOf()
     108                        };
     109
     110                        sessionStorage.setItem(
     111                                sessionStorageKey,
     112                                JSON.stringify( item )
     113                        );
     114                } catch ( e ) {}
    122115        }
    123116
Note: See TracChangeset for help on using the changeset viewer.