You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 30, 2023. It is now read-only.
I think I found a bug in cookie handling. It works fine when I make a remote http request to my html page or if I pass my javascript directly to phantomjs. But when I use a page loader to load my html/javascript locally, cookies are not deleted properly.
<scripttype="text/javascript">functionsetCookie(name,val,timeout){console.log("Setting cookie "+name+" to value "+val);timeout=typeoftimeout!=='undefined' ? timeout : (100*(86400*365));// defaults to 100 yearstimeout*=1000;// ms to secondsvard=newDate();d.setTime(d.getTime()+timeout);varcookie=name+"="+encode(val)+";expires="+d.toUTCString()+";path=/";document.cookie=cookie;}functiongetCookie(name){vari,x,y,c=document.cookie.split(";");for(i=0;i<c.length;i++){x=c[i].substr(0,c[i].indexOf("="));y=c[i].substr(c[i].indexOf("=")+1);x=x.replace(/^\s+|\s+$/g,"");if(x==name){returndecode(y);}}return"";}functionencode(val){if(window.encodeURIComponent){returnencodeURIComponent(val);}else{//noinspection JSDeprecatedSymbolsreturnescape(val);}}functiondecode(val){if(window.decodeURIComponent(val)){returndecodeURIComponent(val);}else{//noinspection JSDeprecatedSymbolsreturnunescape(val);}}functiondeleteCookie(name){console.log("Delete cookie: "+name);document.cookie=name+'=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';}vartestcookie="testcookie";console.log("Testing cookies");setCookie(testcookie,"testValue",300);console.log("Cookie set");console.log("Getting cookie: "+getCookie(testcookie));deleteCookie(testcookie);console.log("Getting cookie after delete: "+getCookie(testcookie));</script>
Put both files in the same directory and then run with:
phantomjs run.js
The expected output is that the last line print:
"Getting cookie after delete: "
but it is actually
"Getting cookie after delete: testValue"
I found this bug because I am using the qunit runner.js to load up my qunit html page, and my test does extensive cookie set/get.
Here is a run with --debug=yes, showing the incorrect expires when calling deleteCookie:
I have experienced a similar issue. Not only can I not delete cookies via QUnit tests, but any cookie I set with an expiration time is ignored (not set).
PhantomJS is a bit more picky in order to remove cookie keys from the document.cookie when compared to Firefox, Chrome or Safari. You have to delete the values with all the proper cookie attributes that you had set into them.
In your example you almost got it, and I've encountered a similar situation myself. Besides an empty value and an expired dateI also had to specify the domain which the cookie is currently set:
Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!
I think I found a bug in cookie handling. It works fine when I make a remote http request to my html page or if I pass my javascript directly to phantomjs. But when I use a page loader to load my html/javascript locally, cookies are not deleted properly.
Here is my test code:
File "run.js":
File "cookiebug.html":
Put both files in the same directory and then run with:
phantomjs run.js
The expected output is that the last line print:
"Getting cookie after delete: "
but it is actually
"Getting cookie after delete: testValue"
I found this bug because I am using the qunit runner.js to load up my qunit html page, and my test does extensive cookie set/get.
Here is a run with --debug=yes, showing the incorrect expires when calling deleteCookie:
The text was updated successfully, but these errors were encountered: