-
Notifications
You must be signed in to change notification settings - Fork 9.4k
13865 safari block cookies breaks javascript scripts #25324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-engcom-team
merged 12 commits into
magento:2.4-develop
from
raulvOnestic91:13865-safari-block-cookies-breaks-javascript-scripts
Feb 9, 2020
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b6bd937
#13865 create a popup to advice about navigator blocked cookies
raulvOnestic91 7e527d8
#13865 remove console log
raulvOnestic91 60117ee
#13865 add scapeHtml to popup text
raulvOnestic91 0c7ac0c
#13865 move translate dependecy and remove declaration
raulvOnestic91 7316201
#13865 move options to wiget's options
raulvOnestic91 ab7c9dc
Merge branch '2.4-develop' of https://github.com/magento/magento2 int…
Nazar65 0ed2bcd
Cover changes with jasmine test
Nazar65 1692711
refactor per review commet, add new cases
Nazar65 78e1386
remove duplicated check
Nazar65 1b1c8bf
rename tests
Nazar65 14112c0
clear test data after each
Nazar65 f7d9193
Merge branch '2.4-develop' into 13865-safari-block-cookies-breaks-jav…
slavvka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/code/Magento/Theme/view/frontend/templates/js/cookie_status.phtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
?> | ||
|
||
<div id="cookie-status" style="display: none"> | ||
<?= $block->escapeHtml(__('The store will not work correctly in the case when cookies are disabled.')); ?> | ||
</div> | ||
|
||
<script type="text/x-magento-init"> | ||
{ | ||
"*": { | ||
"cookieStatus": {} | ||
} | ||
} | ||
</script> | ||
|
||
|
40 changes: 40 additions & 0 deletions
40
app/code/Magento/Theme/view/frontend/web/js/cookie-status.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
define([ | ||
'jquery', | ||
'Magento_Ui/js/modal/modal', | ||
'mage/translate' | ||
], function ($, modal) { | ||
'use strict'; | ||
|
||
$.widget('mage.cookieStatus', { | ||
options: { | ||
type: 'popup', | ||
responsive: true, | ||
innerScroll: true, | ||
autoOpen: true, | ||
buttons: [{ | ||
text: $.mage.__('Close'), | ||
class: 'cookie-status', | ||
|
||
/** | ||
* Callback for click event | ||
*/ | ||
click: function () { | ||
this.closeModal(); | ||
} | ||
}] | ||
}, | ||
|
||
/** | ||
* Init object | ||
* @private | ||
*/ | ||
_init: function () { | ||
|
||
if (!navigator.cookieEnabled) { | ||
modal(this.options, $('#cookie-status')); | ||
} | ||
} | ||
}); | ||
|
||
return $.mage.cookieStatus; | ||
}); |
50 changes: 50 additions & 0 deletions
50
dev/tests/js/jasmine/tests/app/code/Magento/Theme/view/frontend/web/js/cookie-status.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'jquery', | ||
'cookieStatus' | ||
], function ($, Cookie) { | ||
'use strict'; | ||
|
||
describe('Magento_Theme/js/cookie-status', function () { | ||
var widget, | ||
htmlContainer = '<div id="cookie-status" style="display: none"></div>', | ||
navigator; | ||
|
||
beforeEach(function () { | ||
widget = new Cookie(); | ||
navigator = window.navigator; | ||
$('.modal-popup').remove(); | ||
$('#cookie-status').remove(); | ||
$(document.body).append(htmlContainer); | ||
}); | ||
|
||
afterEach(function () { | ||
window.navigator = navigator; | ||
}); | ||
|
||
it('defines cookieStatus widget', function () { | ||
expect($.fn.cookieStatus).toBeDefined(); | ||
}); | ||
|
||
it('does not show a modal when cookies are supported', function () { | ||
window.navigator = { | ||
cookieEnabled: true | ||
}; | ||
widget._init(); | ||
expect($(document.body).html()).not.toContain('<aside role="dialog" class="modal-popup'); | ||
}); | ||
|
||
it('shows the modal when cookies are not supported', function () { | ||
window.navigator = { | ||
cookieEnabled: false | ||
}; | ||
widget._init(); | ||
expect($(document.body).html()).toContain('<aside role="dialog" class="modal-popup'); | ||
krzksz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.