Skip to content

Safari "Block all cookies" setting breaks JavaScript scripts #13865

Closed
@krzksz

Description

@krzksz

Preconditions

  1. Magento 2.2.2 but potentially all versions are affected
  2. Block all cookies setting enabled in Safari privacy options.

Steps to reproduce

  1. Open Safari browser and go to Preferences
  2. In Privacy tab enable Block all cookies setting.
  3. Open any Magento shop.

Expected result

  1. At least the popup with "cookies disabled" message is being displayed.

Actual result

  1. There are multiple SecurityError (DOM Exception 18): The operation is insecure. errors reported in browser's console, some of the scripts work but I can't add anything to the cart.

So it seems like having above setting enabled in Safari will result in above error every time any script is trying to access either window.localStorage or window.sessionStorage including reassigning it. As a result following lines throw errors and most probably prevent shop from functioning properly:

window.localStorage.__proto__ = window.localStorage = new Storage('local');

and also this part of https://github.com/magento/magento2/blob/2.2-develop/lib/web/jquery/jquery.storageapi.min.js:

    function f(e) {
        if (!window[e]) // Error thrown here
            return !1;
        var t = "jsapi";
        try {
            return window[e].setItem(t, t), window[e].removeItem(t), !0
        } catch (r) {
            return !1
        }
    }

I am not sure what would be your preferred solution to this problem but I can gladly prepare a PR when we agree on how we should solve it 👍 .

Metadata

Metadata

Labels

Area: Design/FrontendFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions