cacheoffline.html revision 51cd1e3c989b1d9414c7749c72c369f0325cdb8e
f545d156561c08020a67f9640c51454c2df4fb57fabien<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
f545d156561c08020a67f9640c51454c2df4fb57fabien<script type="text/javascript" src="/build/yui/yui.js"></script>
f545d156561c08020a67f9640c51454c2df4fb57fabien<script type="text/javascript" src="/build/cache/cache-debug.js"></script>
base: "/build/",
var ASSERT = Y.Assert,
ARRAYASSERT = Y.ArrayAssert,
BTNRUN = Y.get("#btnRun");
BTNRUN.set("disabled", false);
Y.on("click", function(e){
var myConsole = new Y.Console().render(),
var testClass = new Y.Test.Case({
var testBasic = new Y.Test.Case({
this.cache.add(1, "a");
this.cache.add(2, "b");
this.cache.set("max", 1);
this.cache.add(3, "c");
this.cache.set("max", null);
this.cache.add(4, "d");
this.cache.add(4, "d");
this.cache.add(1, "a");
this.cache.add("b", "c");
var cachedentry = this.cache.retrieve(1);
cachedentry = this.cache.retrieve("b");
this.cache.add(1, "a");
this.cache.add("b", "c");
var cachedentry = this.cache.retrieve(1);
this.cache.add(1, "a");
var cachedentry = this.cache.retrieve(1);
this.cache.set("expires", 1);
this.cache.add(1, "a");
this.wait(function(){
cachedentry = this.cache.retrieve(1);
ASSERT.isNull(cachedentry, "Expected expired data.");
this.cache.add(1, "a");
var cachedentry = this.cache.retrieve(1);
this.cache.set("expires", new Date(new Date().getTime() - 86400000));
this.cache.add(1, "a");
cachedentry = this.cache.retrieve(1);
ASSERT.isNull(cachedentry, "Expected expired data.");
this.cache.add("a", "b");
var cachedentry = this.cache.retrieve("c");
ASSERT.areSame(null, cachedentry, "Expected no match.");
this.cache.add(1, "a");
this.cache.add(2, "b");
this.cache.add(1, "a");
this.cache.add(2, "b");
var cache = new Y.CacheOffline({sandbox:"another"});
cache.add(1, "a");
cache.add(2, "b");
if(window.localStorage) {
if(window.localStorage) {
var testEvents = new Y.Test.Case({
this.cache.on("add", function(e) {
this.resume(function() {
this.cache.add(1, "a");
this.wait();
this.cache.on("flush", function(e) {
this.cache.detach("flush");
this.resume(function() {
this.cache.add(1, "a");
this.wait();
this.cache.on("request", function(e) {
this.resume(function() {
this.cache.add(1, "a");
this.wait();
this.cache.on("retrieve", function(e) {
this.resume(function() {
this.cache.add(1, "a");
this.wait();
this.cache.on("retrieve", function(e) {
this.resume(function() {
ASSERT.fail();
this.cache.add(1, "a");
this.wait(function() {
this.cache.on("add", function(e) {
this.cache.add(1, "a");
this.cache.on("flush", function(e) {
this.cache.add(1, "a");
var testEntryManagement = new Y.Test.Case({
this.cache.add(1, "a");
this.cache.add(2, "b");
this.cache.add(1, "c");
this.cache.add(1, "a");
this.cache.add(2, "b");
this.cache.add(1, "c");
this.cache.add(1, "a");
this.cache.add(2, "b");
this.cache.add(3, "c");
var testBoundaryValues = new Y.Test.Case({
this.cache.add(undefined, "a");
this.cache.add(undefined, "b");
this.cache.add(null, "a");
this.cache.add(null, "b");
this.cache.add(NaN, "a");
this.cache.add(NaN, "b");
this.cache.add("", "a");
this.cache.add("", "b");
var suite = new Y.Test.Suite({name:"CacheOffline Test Suite"});
suite.add(testClass);
suite.add(testBasic);
suite.add(testEvents);
suite.add(testEntryManagement);
suite.add(testBoundaryValues);
Y.Test.Runner.setName("CacheOffline Test Runner");
Y.Test.Runner.add(suite);
if(window.localStorage) {