Closed
Bug 1027695
Opened 11 years ago
Closed 5 years ago
Setting a cookie in body of document isn't available for reading in loaded js
Categories
(Core :: Networking: Cookies, defect, P3)
Tracking
()
RESOLVED
INVALID
People
(Reporter: robert.wlaschin, Unassigned)
Details
(Whiteboard: [necko-backlog])
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0 (Beta/Release)
Build ID: 20140610163407
Steps to reproduce:
Create a cookie in body of html
e.g.
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
//enable local debugging
setCookie('localOn',1,1);
Load a new js script
e.g.
document.write(unescape("%3Cscript src='/ams/js/tag_os.js' type='text/javascript'%3E%3C/script%3E"));
Try to read the cookie from within the loaded js script
e.g.
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while(c.charAt(0) == ' ') {
c = c.substring(1, c.length);
}
if(c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length, c.length);
}
}
return null;
};
readCookie('localOn');
Actual results:
The cookie was not found
Notes -- when stepping through with debugger problem vanished.
Expected results:
The cookie should have been found with the value of 1
Updated•11 years ago
|
Component: Untriaged → Networking: Cookies
Product: Firefox → Core
Updated•9 years ago
|
Whiteboard: [necko-backlog]
Comment 1•8 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Comment 2•8 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
Comment 3•5 years ago
|
||
This bug looks invalid. We have plenty of similar JS tests about cookies to test this cookie behavior.
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•