Permalink
Browse files

Automated g4 rollback of changelist 218861013.

*** Reason for rollback ***

Change broke tests

*** Original change description ***

Update goog.net.cookies.isEnabled function to, in addition to checking navigator.cookieEnabled, write and immediately read back a garbage cookie to check whether cookies are enabled for a browser.

This in particular protects against the Firefox browser incorrectly reporting cookies are enabled for an iframed site when third party cookies are actually disabled (see https://bugzilla.mozilla.org/show_bug.cgi?id=1500951).

TESTED:
  javascript/closure/bin/run_js_tests.sh javascript/...

***
RELNOTES: n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=218926197
  • Loading branch information...
jplaisted committed Oct 26, 2018
1 parent 8e98199 commit c268a112404847a5aa954e5f45d06e4d53e63821
Showing with 1 addition and 26 deletions.
  1. +1 −26 closure/goog/net/cookies.js
  2. 0 scripts/ci/test_closuredeps.sh
@@ -53,37 +53,12 @@ goog.net.Cookies = function(context) {
goog.net.Cookies.MAX_COOKIE_LENGTH = 3950;


/**
* Test cookie, for better detection on whether third party cookies are
* disabled for certain browsers.
* @private @const {string}
*/
goog.net.Cookies.TEST_COOKIE_ = 'TESTCOOKIESENABLED';


/**
* How long the test cookie should live, if for some reason removal fails.
* @private @const {number}
*/
goog.net.Cookies.TEST_COOKIE_LIFETIME_SECONDS_ = 60;


/**
* Returns true if cookies are enabled.
* @return {boolean} True if cookies are enabled.
*/
goog.net.Cookies.prototype.isEnabled = function() {
// Trust when the navigator says false.
if (!navigator.cookieEnabled) {
return false;
}

// But double check if it says true via writing/reading a test cookie.
this.set(
goog.net.Cookies.TEST_COOKIE_, goog.net.Cookies.TEST_COOKIE_,
goog.net.Cookies.TEST_COOKIE_LIFETIME_SECONDS_);

return this.remove(goog.net.Cookies.TEST_COOKIE_);
return navigator.cookieEnabled;
};


0 scripts/ci/test_closuredeps.sh 100644 → 100755
No changes.

0 comments on commit c268a11

Please sign in to comment.