Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F881902
cookie.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
cookie.html
View Options
<
html
>
<
head
>
<
title
>
testing Cookies
</
title
>
<
style
type
=
"text/css"
>
@
import
"../resources/dojo.css"
;
</
style
>
<
script
type
=
"text/javascript"
src
=
"../dojo.js"
djConfig
=
"isDebug:true"
></
script
>
<
script
type
=
"text/javascript"
src
=
"../cookie.js"
></
script
>
<
script
type
=
"text/javascript"
>
dojo
.
require
(
"doh.runner"
);
dojo
.
addOnLoad
(
function
(){
doh
.
register
(
"t"
,
[
{
name
:
"basicSet"
,
runTest
:
function
(
t
){
// make sure the cookie is dead
var
old
=
new
Date
(
1976
,
8
,
15
);
document
.
cookie
=
"dojo_test=blah; expires="
+
old
.
toUTCString
();
t
.
is
(
-
1
,
document
.
cookie
.
indexOf
(
"dojo_test="
));
// set the new one
var
n
=
"dojo_test"
;
var
v
=
"test value"
;
dojo
.
cookie
(
n
,
v
);
t
.
t
(
document
.
cookie
.
indexOf
(
n
+
"="
)
>=
0
);
var
start
=
document
.
cookie
.
indexOf
(
n
+
"="
)
+
n
.
length
+
1
;
var
end
=
document
.
cookie
.
indexOf
(
";"
,
start
);
if
(
end
==
-
1
)
end
=
document
.
cookie
.
length
;
t
.
is
(
v
,
decodeURIComponent
(
document
.
cookie
.
substring
(
start
,
end
)));
}
},
{
name
:
"basicGet"
,
runTest
:
function
(
t
){
// set the cookie
var
n
=
"dojo_test"
;
var
v
=
"foofoo"
;
document
.
cookie
=
n
+
"="
+
v
;
t
.
is
(
v
,
dojo
.
cookie
(
n
));
}
},
{
name
:
"daysAsNumber"
,
runTest
:
function
(
t
){
// set a cookie with a numerical expires
dojo
.
cookie
(
"dojo_num"
,
"foo"
,
{
expires
:
10
});
t
.
is
(
"foo"
,
dojo
.
cookie
(
"dojo_num"
));
// remove the cookie by setting it with a negative
// numerical expires. value doesn't really matter here
dojo
.
cookie
(
"dojo_num"
,
"-deleted-"
,
{
expires
:
-
10
});
t
.
is
(
null
,
dojo
.
cookie
(
"dojo_num"
));
}
}
]
);
doh
.
run
();
})
</
script
>
</
head
>
<
body
>
</
body
>
</
html
>
File Metadata
Details
Attached
Mime Type
text/html
Expires
Wed, Apr 2, 13:34 (4 w, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25781
Default Alt Text
cookie.html (1 KB)
Attached To
rZEDHG ZedLegacy
Event Timeline
Log In to Comment