Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding appcache test. #3

Merged
merged 1 commit into from

2 participants

@mattwkelly

No description provided.

@darobin darobin merged commit 1eba762 into coremob:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 10, 2012
  1. @mattwkelly

    Adding appcache test.

    mattwkelly authored
This page is out of date. Refresh to see the latest.
View
4 tests/appcache/config.yml
@@ -0,0 +1,4 @@
+---
+ r: 0
+ spec: "http://www.w3.org/TR/html5/offline.html"
+ title: "Application Cache"
View
13 tests/appcache/example.appcache.php
@@ -0,0 +1,13 @@
+<?php
+$code = ($_COOKIE["online"] === "true") ? 410 : 200;
+header("Content-type: text/cache-manifest", true, $code);
+?>CACHE MANIFEST
+# 2012-02-07-v0.0.1
+
+# Explicitly cached entries
+CACHE:
+/tests/appcache/png.png
+
+# Resources that require the user to be online.
+NETWORK:
+*
View
1  tests/appcache/fixture.html
@@ -0,0 +1 @@
+<!-- <iframe id="appcache" src="/tests/appcache/iframe.html"></iframe> -->
View
3  tests/appcache/iframe.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<html manifest="/tests/appcache/example.appcache.php">
+</html>
View
BIN  tests/appcache/png.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
59 tests/appcache/test.js
@@ -0,0 +1,59 @@
+test("applicationCache (Offline Support)", function() {
+ var applicationCache = H.API( window, "applicationCache", true );
+
+ assert( applicationCache, "applicationCache supported" );
+});
+
+// oncached: null
+// onchecking: null
+// ondownloading: null
+// onerror: null
+// onnoupdate: null
+// onobsolete: null
+// onprogress: null
+// onupdateready: null
+// status: 0
+
+
+// asyncTest("applicationCache In Practice", function( async ) {
+// var iframe = document.getElementById("appcache").contentWindow,
+// appcache = iframe.applicationCache,
+// // TODO: Refactor this to be used with any cookie key=value
+// setCookie = function( time ) {
+// document.cookie = "online=true; expires=" + ((new Date()).getTime() + time);
+// };
+//
+// // Set a cookie to be read by example.appcache.php,
+// // this is _required_ to work around issues with the
+// // applicationCache spec behaviour where it caches the
+// // first time, but will not re-read the cache unless
+// // otherwise told to do so. Normally, this might involve
+// // manually clearing the application cache - such facilities
+// // are available in limited access forms,
+// // eg. chrome://appcache-internals/
+// //
+// // In order to artificially cause an update to occur, we can
+// // set a cookie here, that will be read by example.appcache.php
+// // and respond with a HTTP 410
+// // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.11
+// // ... this will effectively "trick" the applicationCache API
+// // into believing the manifest is gone, causing the "checking"
+// // process to be re-run.
+// setCookie( 2600 );
+//
+// setTimeout(function ready() {
+// if ( appcache.status > 0 ) {
+//
+// assert( !!appcache.status, "appcache.status" );
+//
+// async.done();
+//
+// // Expire the cookie to enusre the test is run correctly,
+// // without interference from applicationCache, every time.
+// setCookie( -2600 );
+//
+// } else {
+// setTimeout( ready, 10 );
+// }
+// }, 10);
+// });
Something went wrong with that request. Please try again.