Backed out changeset 2507a02fae1a (bug 1153521) for frequent test failures in cache-add.https.html

This commit is contained in:
Carsten "Tomcat" Book 2015-04-12 11:33:04 +02:00
Родитель 6cb3868c1d
Коммит 4c39a7340a
92 изменённых файлов: 98 добавлений и 3132 удалений

Просмотреть файл

@ -709,14 +709,6 @@
"path": "html/semantics/forms/the-input-element/file-manual.html",
"url": "/html/semantics/forms/the-input-element/file-manual.html"
},
{
"path": "html/semantics/forms/the-textarea-element/textarea-select-event-manual.html",
"url": "/html/semantics/forms/the-textarea-element/textarea-select-event-manual.html"
},
{
"path": "html/semantics/forms/the-textarea-element/textarea-select-manual.html",
"url": "/html/semantics/forms/the-textarea-element/textarea-select-manual.html"
},
{
"path": "html/semantics/grouping-content/the-li-element/grouping-li-novalue-manual.html",
"url": "/html/semantics/grouping-content/the-li-element/grouping-li-novalue-manual.html"
@ -8415,6 +8407,10 @@
"path": "IndexedDB/idbdatabase_createObjectStore7.htm",
"url": "/IndexedDB/idbdatabase_createObjectStore7.htm"
},
{
"path": "IndexedDB/idbdatabase_createObjectStore8-parameters.htm",
"url": "/IndexedDB/idbdatabase_createObjectStore8-parameters.htm"
},
{
"path": "IndexedDB/idbdatabase_createObjectStore9-invalidparameters.htm",
"url": "/IndexedDB/idbdatabase_createObjectStore9-invalidparameters.htm"
@ -9699,6 +9695,58 @@
"path": "XMLHttpRequest/xmlhttprequest-network-error.htm",
"url": "/XMLHttpRequest/xmlhttprequest-network-error.htm"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-aborted.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-aborted.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-overrides.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-overrides.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-simple.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-simple.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-synconmain.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-synconmain.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-twice.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-twice.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-unsent.htm",
"url": "/XMLHttpRequest/xmlhttprequest-unsent.htm"
@ -10227,10 +10275,6 @@
"path": "dom/nodes/CharacterData-replaceData.html",
"url": "/dom/nodes/CharacterData-replaceData.html"
},
{
"path": "dom/nodes/CharacterData-substringData.html",
"url": "/dom/nodes/CharacterData-substringData.html"
},
{
"path": "dom/nodes/Comment-constructor.html",
"url": "/dom/nodes/Comment-constructor.html"
@ -11191,30 +11235,6 @@
"path": "ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html",
"url": "/ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html"
},
{
"path": "fetch/nosniff/image.html",
"url": "/fetch/nosniff/image.html"
},
{
"path": "fetch/nosniff/importscripts.html",
"url": "/fetch/nosniff/importscripts.html"
},
{
"path": "fetch/nosniff/parsing-nosniff.html",
"url": "/fetch/nosniff/parsing-nosniff.html"
},
{
"path": "fetch/nosniff/script.html",
"url": "/fetch/nosniff/script.html"
},
{
"path": "fetch/nosniff/stylesheet.html",
"url": "/fetch/nosniff/stylesheet.html"
},
{
"path": "fetch/nosniff/worker.html",
"url": "/fetch/nosniff/worker.html"
},
{
"path": "gamepad/idlharness.html",
"url": "/gamepad/idlharness.html"
@ -16087,98 +16107,6 @@
"path": "selectors/attribute-selectors/attribute-case/syntax.html",
"url": "/selectors/attribute-selectors/attribute-case/syntax.html"
},
{
"path": "service-workers/cache-storage/common.https.html",
"url": "/service-workers/cache-storage/common.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-add.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-add.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-delete.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-delete.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-match.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-match.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-put.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-put.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-storage-keys.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-storage-keys.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-storage-match.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-storage-match.https.html"
},
{
"path": "service-workers/cache-storage/serviceworker/cache-storage.https.html",
"url": "/service-workers/cache-storage/serviceworker/cache-storage.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-add.https.html",
"url": "/service-workers/cache-storage/window/cache-add.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-delete.https.html",
"url": "/service-workers/cache-storage/window/cache-delete.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-match.https.html",
"url": "/service-workers/cache-storage/window/cache-match.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-put.https.html",
"url": "/service-workers/cache-storage/window/cache-put.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-storage-keys.https.html",
"url": "/service-workers/cache-storage/window/cache-storage-keys.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-storage-match.https.html",
"url": "/service-workers/cache-storage/window/cache-storage-match.https.html"
},
{
"path": "service-workers/cache-storage/window/cache-storage.https.html",
"url": "/service-workers/cache-storage/window/cache-storage.https.html"
},
{
"path": "service-workers/cache-storage/window/sandboxed-iframes.https.html",
"url": "/service-workers/cache-storage/window/sandboxed-iframes.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-add.https.html",
"url": "/service-workers/cache-storage/worker/cache-add.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-delete.https.html",
"url": "/service-workers/cache-storage/worker/cache-delete.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-match.https.html",
"url": "/service-workers/cache-storage/worker/cache-match.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-put.https.html",
"url": "/service-workers/cache-storage/worker/cache-put.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-storage-keys.https.html",
"url": "/service-workers/cache-storage/worker/cache-storage-keys.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-storage-match.https.html",
"url": "/service-workers/cache-storage/worker/cache-storage-match.https.html"
},
{
"path": "service-workers/cache-storage/worker/cache-storage.https.html",
"url": "/service-workers/cache-storage/worker/cache-storage.https.html"
},
{
"path": "shadow-dom/elements-and-dom-objects/extensions-to-element-interface/attributes/test-001.html",
"url": "/shadow-dom/elements-and-dom-objects/extensions-to-element-interface/attributes/test-001.html"
@ -18824,11 +18752,6 @@
"timeout": "long",
"url": "/IndexedDB/idbdatabase_createObjectStore10-1000ends.htm"
},
{
"path": "IndexedDB/idbdatabase_createObjectStore8-parameters.htm",
"timeout": "long",
"url": "/IndexedDB/idbdatabase_createObjectStore8-parameters.htm"
},
{
"path": "IndexedDB/idbobjectstore_createIndex3-usable-right-away.htm",
"timeout": "long",
@ -18864,71 +18787,6 @@
"timeout": "long",
"url": "/XMLHttpRequest/send-redirect-bogus.htm"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-aborted.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-aborted.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-overrides.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-overrides.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-simple.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-simple.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-synconmain.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-synconmain.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-twice.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-twice.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html"
},
{
"path": "XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html",
"timeout": "long",
"url": "/XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html"
},
{
"path": "ambient-light/AmbientLight_tests.html",
"timeout": "long",
@ -24715,7 +24573,7 @@
}
]
},
"rev": "7311aa630534282885b9add15b1c30b2b59316dd",
"rev": "1bb38c25b4720fbfd8ca086ef9275ac3e465c659",
"url_base": "/",
"version": 2
}

Просмотреть файл

@ -1 +1 @@
cb3abe0063c59cf9273978c8db7700838bf835ad
6b7e4ef6d1fc15effa2576de3aec04b818b3f58f

Просмотреть файл

@ -2,7 +2,6 @@
<meta charset="utf-8">
<title>IDBObjectStoreParameters</title>
<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>

Просмотреть файл

@ -1,16 +1,8 @@
The Web Platform Tests Project [![IRC chat](https://goo.gl/6nCIks)](http://irc.w3.org/?channels=testing)
==============================
The Web Platform Tests Project is a W3C-coordinated attempt to build a
cross-browser testsuite for the Web-platform stack. Writing tests in a
way that allows them to be run in all browsers gives browser projects
confidence that they are shipping software that is compatible with other
implementations, and that later implementations will be compatible with
their implementations. This in turn gives Web authors/developers
confidence that they can actually rely on the Web platform to deliver on
the promise of working across browsers and devices without needing extra
layers of abstraction to paper over the gaps left by specification
editors and implementors.
These are test suites for 60+ Web-platform specifications, along
with test-infrastructure code for running the tests.
Running the Tests
=================

Просмотреть файл

@ -10,7 +10,7 @@ def main(request, response):
response.write_status_headers()
for value in chunks:
response.writer.write("%x\r\n" % len(value))
response.writer.write("%d\r\n" % len(value))
response.writer.write(value)
response.writer.write("\r\n")
response.writer.write("0\r\n")

Просмотреть файл

@ -2,14 +2,14 @@ if (this.document === undefined)
importScripts("xmlhttprequest-timeout.js");
/*
This sets up three requests:
The first request will only be open()ed, not aborted, timeout will be TIME_REGULAR_TIMEOUT but will never triggered because send() isn't called.
After TIME_NORMAL_LOAD, the test asserts that no load/error/timeout/abort events fired
The first request will only be open()ed, not aborted, timeout will be 400 but will never triggered because send() isn't called.
After a 1 second delay, the test asserts that no load/error/timeout/abort events fired
Second request will be aborted immediately after send(), test asserts that abort fired
Third request is set up to call abort() after TIME_NORMAL_LOAD, but it also has a TIME_REGULAR_TIMEOUT timeout. Asserts that timeout fired.
(abort() is called later and should not fire an abort event per spec. This is untested!)
Third request is set up to call abort() after a 1 second delay, but it also has a 400ms timeout. Asserts that timeout fired.
(abort() is called 600ms later and should not fire an abort event per spec. This is untested!)
*/
runTestRequests([ new AbortedRequest(false),
new AbortedRequest(true, -1),
new AbortedRequest(true, TIME_NORMAL_LOAD) ]);
new AbortedRequest(true, -1),
new AbortedRequest(true, TIME_NORMAL_LOAD) ]);

Просмотреть файл

@ -1,8 +1,8 @@
/*
This test sets up two requests:
This test sets up two requests:
one that gets abort()ed from a 0ms timeout (0ms will obviously be clamped to whatever the implementation's minimal value is), asserts abort event fires
one that will be aborted after TIME_DELAY, (with a timeout at TIME_REGULAR_TIMEOUT) asserts abort event fires. Does not assert that the timeout event does *not* fire.
one that will be aborted after 200ms (TIME_DELAY), (with a timeout at 400ms) asserts abort event fires. Does not assert that the timeout event does *not* fire.
*/
runTestRequests([ new AbortedRequest(true, 0),
new AbortedRequest(true, TIME_DELAY) ]);
new AbortedRequest(true, TIME_DELAY) ]);

Просмотреть файл

@ -2,10 +2,10 @@ if (this.document === undefined)
importScripts("xmlhttprequest-timeout.js");
/*
Sets up three requests to a resource that will take 0.6 seconds to load:
1) timeout first set to TIME_NORMAL_LOAD, after TIME_REGULAR_TIMEOUT timeout is set to 0, asserts load fires
2) timeout first set to TIME_NORMAL_LOAD, after TIME_DELAY timeout is set to TIME_REGULAR_TIMEOUT, asserts load fires (race condition..?!?)
3) timeout first set to 0, after TIME_REGULAR_TIMEOUT it is set to TIME_REGULAR_TIMEOUT * 10, asserts load fires
1) timeout first set to 1000ms, after 400ms timeout is set to 0, asserts load fires
2) timeout first set to 1000ms, after 200ms timeout is set to 400, asserts load fires (race condition..?!?)
3) timeout first set to 0, after 400ms it is set to 1000, asserts load fires
*/
runTestRequests([ new RequestTracker(true, "timeout disabled after initially set", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, 0),
new RequestTracker(true, "timeout overrides load after a delay", TIME_NORMAL_LOAD, TIME_DELAY, TIME_REGULAR_TIMEOUT),
new RequestTracker(true, "timeout enabled after initially disabled", 0, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD * 10) ]);
new RequestTracker(true, "timeout overrides load after a delay", TIME_NORMAL_LOAD, TIME_DELAY, TIME_REGULAR_TIMEOUT),
new RequestTracker(true, "timeout enabled after initially disabled", 0, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD * 10) ]);

Просмотреть файл

@ -1,12 +1,13 @@
if (this.document === undefined)
importScripts("xmlhttprequest-timeout.js");
/*
Starts three requests:
1) XHR to resource which will take a least TIME_XHR_LOAD ms with timeout initially set to TIME_NORMAL_LOAD ms. After TIME_LATE_TIMEOUT ms timeout is supposedly reset to TIME_DELAY ms,
but the resource should have finished loading already. Asserts "load" fires.
2) XHR with initial timeout set to TIME_NORMAL_LOAD, after TIME_REGULAR_TIMEOUT sets timeout to TIME_DELAY+100. Asserts "timeout" fires.
3) XHR with initial timeout set to TIME_DELAY, after TIME_REGULAR_TIMEOUT sets timeout to 500ms. Asserts "timeout" fires (the change happens when timeout already fired and the request is done).
Starts three requests:
1) XHR to resource which will take a least 600ms with timeout initially set to 1000ms. After 800ms timeout is supposedly reset to 200ms,
but the resource should have finished loading already. Asserts "load" fires.
2) XHR with initial timeout set to 1000, after 400ms sets timeout to 300ms. Asserts "timeout" fires.
(Originally new value was 200ms. Race condition-y. Setting the new timeout to 300ms would be a better test of the "measured from start of fetching" requirement.)
3) XHR with initial timeout set to 200, after 400ms sets timeout to 500ms. Asserts "timeout" fires (the change happens when timeout already fired and the request is done).
*/
runTestRequests([ new RequestTracker(true, "timeout set to expiring value after load fires", TIME_NORMAL_LOAD, TIME_LATE_TIMEOUT, TIME_DELAY),
new RequestTracker(true, "timeout set to expired value before load fires", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_DELAY+100),
new RequestTracker(true, "timeout set to non-expiring value after timeout fires", TIME_DELAY, TIME_REGULAR_TIMEOUT, 500) ]);
new RequestTracker(true, "timeout set to expired value before load fires", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, TIME_DELAY+100),
new RequestTracker(true, "timeout set to non-expiring value after timeout fires", TIME_DELAY, TIME_REGULAR_TIMEOUT, 500) ]);

Просмотреть файл

@ -1,4 +1,3 @@
function testResultCallbackHandler(event) {
if (event.data == "done") {
done();
@ -17,5 +16,5 @@ function testResultCallbackHandler(event) {
window.addEventListener("message", testResultCallbackHandler);
// Setting up testharness.js
setup({ explicit_done: true });
setup({ explicit_done: true, timeout: 30 * 1000 });

Просмотреть файл

@ -11,12 +11,12 @@
request handlers.
*/
var TIME_NORMAL_LOAD = 5000;
var TIME_LATE_TIMEOUT = 4000;
var TIME_XHR_LOAD = 3000;
var TIME_REGULAR_TIMEOUT = 2000;
var TIME_SYNC_TIMEOUT = 1000;
var TIME_DELAY = 1000;
var TIME_NORMAL_LOAD = 1000;
var TIME_LATE_TIMEOUT = 800;
var TIME_XHR_LOAD = 600;
var TIME_REGULAR_TIMEOUT = 400;
var TIME_SYNC_TIMEOUT = 200;
var TIME_DELAY = 200;
/*
* This should point to a resource that responds with a text/plain resource after a delay of TIME_XHR_LOAD milliseconds.

Просмотреть файл

@ -12,7 +12,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -8,7 +8,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#event-xhr-abort" data-tested-assertations="../.." />
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol/li[9]"/>
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -8,7 +8,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -9,7 +9,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -9,7 +9,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -6,7 +6,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[1]" />
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol[1]/li[10]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -10,7 +10,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout.js"></script>

Просмотреть файл

@ -12,7 +12,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout-runner.js"></script>

Просмотреть файл

@ -8,7 +8,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout-runner.js"></script>

Просмотреть файл

@ -9,7 +9,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout-runner.js"></script>

Просмотреть файл

@ -9,7 +9,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout-runner.js"></script>
@ -20,7 +19,7 @@
<div id="log"></div>
<script type="text/javascript">
var worker = new Worker("resources/xmlhttprequest-timeout-simple.js");
worker.onmessage = testResultCallbackHandler;
worker.onmessage = testResultCallbackHandler;
</script>
</body>
</html>

Просмотреть файл

@ -9,7 +9,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout-runner.js"></script>

Просмотреть файл

@ -9,7 +9,6 @@
<link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
<link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
<link rel="stylesheet" href="/resources/testharness.css" />
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/xmlhttprequest-timeout-runner.js"></script>

Просмотреть файл

@ -1,108 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.substringData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-substringdata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// TODO: non-ASCII strings
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws(new TypeError(), function() { node.substringData() })
assert_throws(new TypeError(), function() { node.substringData(0) })
}, type + ".substringData() with too few arguments")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1, "test"), "t")
}, type + ".substringData() with too many arguments")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("IndexSizeError", function() { node.substringData(5, 0) })
assert_throws("IndexSizeError", function() { node.substringData(6, 0) })
assert_throws("IndexSizeError", function() { node.substringData(-1, 0) })
}, type + ".substringData() with invalid offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1), "t")
assert_equals(node.substringData(1, 1), "e")
assert_equals(node.substringData(2, 1), "s")
assert_equals(node.substringData(3, 1), "t")
assert_equals(node.substringData(4, 1), "")
}, type + ".substringData() with in-bounds offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0x100000000 + 0, 1), "t")
assert_equals(node.substringData(0x100000000 + 1, 1), "e")
assert_equals(node.substringData(0x100000000 + 2, 1), "s")
assert_equals(node.substringData(0x100000000 + 3, 1), "t")
assert_equals(node.substringData(0x100000000 + 4, 1), "")
}, type + ".substringData() with very large offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(-0x100000000 + 2, 1), "s")
}, type + ".substringData() with negative offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData("test", 3), "tes")
}, type + ".substringData() with string offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1), "t")
assert_equals(node.substringData(0, 2), "te")
assert_equals(node.substringData(0, 3), "tes")
assert_equals(node.substringData(0, 4), "test")
}, type + ".substringData() with in-bounds count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 5), "test")
assert_equals(node.substringData(2, 20), "st")
}, type + ".substringData() with large count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(2, 0x100000000 + 1), "s")
}, type + ".substringData() with very large count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, -1), "test")
assert_equals(node.substringData(0, -0x100000000 + 2), "te")
}, type + ".substringData() with negative count")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

Просмотреть файл

@ -318,17 +318,4 @@ test(function() {
assert_equals(a.firstChild, c);
assert_equals(c.parentNode, a);
}, "replaceChild should work in the presence of mutation events.")
test(function() {
var TEST_ID = "findme";
var gBody = document.getElementsByTagName("body")[0];
var parent = document.createElement("div");
gBody.appendChild(parent);
var child = document.createElement("div");
parent.appendChild(child);
var df = document.createDocumentFragment();
var fragChild = df.appendChild(document.createElement("div"));
fragChild.setAttribute("id", TEST_ID);
parent.replaceChild(df, child);
assert_equals(document.getElementById(TEST_ID), fragChild, "should not be null");
}, "Replacing an element with a DocumentFragment should allow a child of the DocumentFragment to be found by Id.")
</script>

Просмотреть файл

@ -385,13 +385,4 @@ test(function() {
el.removeAttributeNS(null, "pre:fix")
assert_equals(el.attributes[0], unprefixed)
}, "Attribute with prefix in local name")
test(function() {
var el = document.createElement("div")
el.setAttribute("foo", "bar")
var attr = el.attributes[0]
assert_equals(attr.ownerElement, el)
el.removeAttribute("foo")
assert_equals(attr.ownerElement, null)
}, "Attribute loses its owner when removed")
</script>

Просмотреть файл

@ -1,29 +0,0 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var fails = ["", "?type=", "?type=x", "?type=x/x"],
passes = ["?type=image/gif", "?type=image/png", "?type=image/png;blah"]
fails.forEach(function(urlpart) {
async_test(function(t) {
var img = document.createElement("img")
img.onerror = t.step_func_done(function(){})
img.onload = t.unreached_func("Unexpected load event")
img.src = "resources/image.py" + urlpart
document.body.appendChild(img)
}, "URL query: " + urlpart)
})
passes.forEach(function(urlpart) {
async_test(function(t) {
var img = document.createElement("img")
img.onerror = t.unreached_func("Unexpected error event")
img.onload = t.step_func_done(function(){
assert_equals(img.width, 96)
})
img.src = "resources/image.py" + urlpart
document.body.appendChild(img)
}, "URL query: " + urlpart)
})
</script>

Просмотреть файл

@ -1,14 +0,0 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
async_test(function(t) {
var w = new Worker("importscripts.js")
w.onmessage = t.step_func(function(e) {
if(e.data == "END")
t.done()
else
assert_equals(e.data, "PASS")
})
}, "Test importScripts()")
</script>

Просмотреть файл

@ -1,17 +0,0 @@
// Testing importScripts()
function log(w) { this.postMessage(w) }
function f() { log("FAIL") }
function p() { log("PASS") }
["", "?type=", "?type=x", "?type=x/x"].forEach(function(urlpart) {
try {
importScripts("resources/js.py" + urlpart)
} catch(e) {
(e.name == "NetworkError") ? p() : log("FAIL (no NetworkError exception): " + urlpart)
}
})
importScripts("resources/js.py?type=text/javascript&outcome=p")
importScripts("resources/js.py?type=text/ecmascript&outcome=p")
importScripts("resources/js.py?type=text/ecmascript;blah&outcome=p")
log("END")

Просмотреть файл

@ -1,28 +0,0 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var fails = ["first", "uppercase"],
passes = ["last", "quoted", "quoted-single", "no-x"]
fails.forEach(function(urlpart) {
async_test(function(t) {
var script = document.createElement("script")
script.onerror = t.step_func_done(function(){})
script.onload = t.unreached_func("Unexpected load event")
script.src = "resources/nosniff-" + urlpart + ".asis"
document.body.appendChild(script)
}, "URL query: " + urlpart)
})
passes.forEach(function(urlpart) {
async_test(function(t) {
var script = document.createElement("script")
script.onerror = t.unreached_func("Unexpected error event")
script.onload = t.step_func_done(function(){})
script.src = "resources/nosniff-" + urlpart + ".asis"
document.body.appendChild(script)
}, "URL query: " + urlpart)
})
</script>

Просмотреть файл

@ -1,15 +0,0 @@
def main(request, response):
outcome = request.GET.first("outcome", "f")
type = request.GET.first("type", None)
content = "/* nothing to see here */"
response.add_required_headers = False
response.writer.write_status(200)
response.writer.write_header("x-content-type-options", "nosniff")
response.writer.write_header("content-length", len(content))
if(type != None):
response.writer.write_header("content-type", type)
response.writer.end_headers()
response.writer.write(content)

Просмотреть файл

@ -1,16 +0,0 @@
import os.path
def main(request, response):
type = request.GET.first("type", None)
body = open(os.path.join(os.path.dirname(__file__), "../../../images/blue96x96.png")).read()
response.add_required_headers = False
response.writer.write_status(200)
response.writer.write_header("x-content-type-options", "nosniff")
response.writer.write_header("content-length", len(body))
if(type != None):
response.writer.write_header("content-type", type)
response.writer.end_headers()
response.writer.write(body)

Просмотреть файл

@ -1,17 +0,0 @@
def main(request, response):
outcome = request.GET.first("outcome", "f")
type = request.GET.first("type", "Content-Type missing")
content = "// nothing to see here"
content += "\n"
content += "log('FAIL: " + type + "')" if (outcome == "f") else "p()"
response.add_required_headers = False
response.writer.write_status(200)
response.writer.write_header("x-content-type-options", "nosniff")
response.writer.write_header("content-length", len(content))
if(type != "Content-Type missing"):
response.writer.write_header("content-type", type)
response.writer.end_headers()
response.writer.write(content)

Просмотреть файл

@ -1,7 +0,0 @@
HTTP/1.1 200 YOU HAVE NO POWER HERE
Content-Length: 22
Content-Type: x/x
X-Content-Type-options: nosniff
X-Content-Type-Options: no
// nothing to see here

Просмотреть файл

@ -1,7 +0,0 @@
HTTP/1.1 200 YOU HAVE NO POWER HERE
Content-Length: 22
Content-Type: x/x
X-Content-Type-Options: no
X-Content-Type-options: nosniff
// nothing to see here

Просмотреть файл

@ -1,6 +0,0 @@
HTTP/1.1 200 YOU HAVE NO POWER HERE
Content-Length: 22
Content-Type: x/x
Content-Type-Options: nosniff
// nothing to see here

Просмотреть файл

@ -1,6 +0,0 @@
HTTP/1.1 200 YOU HAVE NO POWER HERE
Content-Length: 22
Content-Type: x/x
X-Content-Type-Options: 'NosniFF'
// nothing to see here

Просмотреть файл

@ -1,6 +0,0 @@
HTTP/1.1 200 YOU HAVE NO POWER HERE
Content-Length: 22
Content-Type: x/x
X-Content-Type-Options: "nosniFF"
// nothing to see here

Просмотреть файл

@ -1,6 +0,0 @@
HTTP/1.1 200 YOU HAVE NO POWER HERE
Content-Length: 22
Content-Type: x/x
X-Content-Type-Options: NOSNIFF
// nothing to see here

Просмотреть файл

@ -1,16 +0,0 @@
def main(request, response):
type = request.GET.first("type", None)
content = "// nothing to see here"
content += "\n"
content += "this.postMessage('hi')"
response.add_required_headers = False
response.writer.write_status(200)
response.writer.write_header("x-content-type-options", "nosniff")
response.writer.write_header("content-length", len(content))
if(type != None):
response.writer.write_header("content-type", type)
response.writer.end_headers()
response.writer.write(content)

Просмотреть файл

@ -1,32 +0,0 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var log = function() {}, // see comment below
p = function() {}, // see comment below
fails = ["", "?type=", "?type=x", "?type=x/x"],
passes = ["?type=text/javascript", "?type=text/ecmascript", "?type=text/ecmascript;blah"]
// Ideally we'd also check whether the scripts in fact execute, but that would involve
// timers and might get a bit racy without cross-browser support for the execute events.
fails.forEach(function(urlpart) {
async_test(function(t) {
var script = document.createElement("script")
script.onerror = t.step_func_done(function(){})
script.onload = t.unreached_func("Unexpected load event")
script.src = "resources/js.py" + urlpart
document.body.appendChild(script)
}, "URL query: " + urlpart)
})
passes.forEach(function(urlpart) {
async_test(function(t) {
var script = document.createElement("script")
script.onerror = t.unreached_func("Unexpected error event")
script.onload = t.step_func_done(function(){})
script.src = "resources/js.py" + urlpart + "&outcome=p"
document.body.appendChild(script)
}, "URL query: " + urlpart)
})
</script>

Просмотреть файл

@ -1,34 +0,0 @@
<!-- quirks mode is important, text/css is already required otherwise -->
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var fails = ["", "?type=", "?type=x", "?type=x/x"],
passes = ["?type=text/css", "?type=text/css;blah"]
fails.forEach(function(urlpart) {
async_test(function(t) {
var link = document.createElement("link")
link.rel = "stylesheet"
link.onerror = t.step_func_done(function(){})
link.onload = t.unreached_func("Unexpected load event")
link.href = "resources/css.py" + urlpart
document.body.appendChild(link)
}, "URL query: " + urlpart)
})
passes.forEach(function(urlpart) {
async_test(function(t) {
var link = document.createElement("link")
link.rel = "stylesheet"
link.onerror = t.unreached_func("Unexpected error event")
link.onload = t.step_func_done(function(){
if(passes[passes.length-1] == urlpart) {
assert_equals(document.styleSheets.length, passes.length)
}
})
link.href = "resources/css.py" + urlpart
document.body.appendChild(link)
}, "URL query: " + urlpart)
})
</script>

Просмотреть файл

@ -1,28 +0,0 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
var workers = [],
fails = ["", "?type=", "?type=x", "?type=x/x"],
passes = ["?type=text/javascript", "?type=text/ecmascript", "?type=text/ecmascript;yay"]
fails.forEach(function(urlpart) {
async_test(function(t) {
var w = new Worker("resources/worker.py" + urlpart)
w.onmessage = t.unreached_func("Unexpected message event")
w.onerror = t.step_func_done(function(){})
workers.push(w) // avoid GC
}, "URL query: " + urlpart)
})
passes.forEach(function(urlpart) {
async_test(function(t) {
var w = new Worker("resources/worker.py" + urlpart)
w.onmessage = t.step_func_done(function(e){
assert_equals(e.data, "hi")
})
w.onerror = t.unreached_func("Unexpected error event")
workers.push(w) // avoid GC
}, "URL query: " + urlpart)
})
</script>

Просмотреть файл

@ -1,31 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTMLTextAreaElement Test: select event</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<meta name="flags" content="interact">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<p>Select any numberic characters in the text area below</p>
<form id="testForm" name="testForm">
<textarea id="testtextarea">0123456789</textarea>
</form>
<script>
var textarea = document.getElementById("testtextarea");
setup({explicit_done : true});
setup({explicit_timeout : true});
on_event(textarea, "select", function(evt) {
test(function() {
assert_greater_than(textarea.value.substring(textarea.selectionStart, textarea.selectionEnd).length, 0, "Check if select event captured when text selected");
});
done();
});
</script>
<div id="log"></div>

Просмотреть файл

@ -1,13 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTMLTextAreaElement Test: select()</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<meta name="flags" content="interact">
<p>Test passes if content of the input area is selected</p>
<textarea id="test_obj">1234567</textarea>
<script>
var textarea = document.querySelector("#test_obj");
textarea.select();
</script>

Просмотреть файл

@ -15,7 +15,7 @@
var script=testlib.addScript('', { src:'scripts/include-1.js?pipe=trickle(d1)&'+Math.random() }, document.getElementsByTagName('head')[0], false );
log('end script #1');
</script>
<script src="scripts/include-2.js?pipe=trickle(d4)"></script>
<script src="scripts/include-2.js?pipe=trickle(d2)"></script>
<script type="text/javascript">
var t = async_test()

Просмотреть файл

@ -1,51 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: Verify that Window and Workers see same storage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script>
function wait_for_message(worker) {
return new Promise(function(resolve) {
worker.addEventListener('message', function listener(e) {
resolve(e.data);
worker.removeEventListener('message', listener);
});
});
}
promise_test(function(t) {
var cache_name = 'common-test';
return self.caches.delete(cache_name)
.then(function() {
var worker = new Worker('resources/common-worker.js');
worker.postMessage({name: cache_name});
return wait_for_message(worker);
})
.then(function(message) {
return self.caches.open(cache_name);
})
.then(function(cache) {
return Promise.all([
cache.match('https://example.com/a'),
cache.match('https://example.com/b'),
cache.match('https://example.com/c')
]);
})
.then(function(responses) {
return Promise.all(responses.map(
function(response) { return response.text(); }
));
})
.then(function(bodies) {
assert_equals(bodies[0], 'a',
'Body should match response put by worker');
assert_equals(bodies[1], 'b',
'Body should match response put by worker');
assert_equals(bodies[2], 'c',
'Body should match response put by worker');
});
}, 'Window sees cache puts by Worker');
</script>

Просмотреть файл

@ -1,2 +0,0 @@
<!DOCTYPE html>
<title>Empty doc</title>

Просмотреть файл

@ -1,15 +0,0 @@
self.onmessage = function(e) {
var cache_name = e.data.name;
self.caches.open(cache_name)
.then(function(cache) {
return Promise.all([
cache.put('https://example.com/a', new Response('a')),
cache.put('https://example.com/b', new Response('b')),
cache.put('https://example.com/c', new Response('c'))
]);
})
.then(function() {
self.postMessage('ok');
});
};

Просмотреть файл

@ -1,2 +0,0 @@
def main(request, response):
return int(request.GET["status"]), [], ""

Просмотреть файл

@ -1,13 +0,0 @@
<!DOCTYPE html>
<title>ok</title>
<script>
window.onmessage = function(e) {
var id = e.data.id;
try {
self.caches;
window.parent.postMessage({id: id, result: 'allowed'}, '*');
} catch (e) {
window.parent.postMessage({id: id, result: 'denied', name: e.name, message: e.message}, '*');
}
};
</script>

Просмотреть файл

@ -1 +0,0 @@
a simple text file

Просмотреть файл

@ -1,37 +0,0 @@
(function() {
var next_cache_index = 1;
// Returns a promise that resolves to a newly created Cache object. The
// returned Cache will be destroyed when |test| completes.
function create_temporary_cache(test) {
var uniquifier = String(++next_cache_index);
var cache_name = self.location.pathname + '/' + uniquifier;
test.add_cleanup(function() {
self.caches.delete(cache_name);
});
return self.caches.delete(cache_name)
.then(function() {
return self.caches.open(cache_name);
});
}
self.create_temporary_cache = create_temporary_cache;
})();
// Runs |test_function| with a temporary unique Cache passed in as the only
// argument. The function is run as a part of Promise chain owned by
// promise_test(). As such, it is expected to behave in a manner identical (with
// the exception of the argument) to a function passed into promise_test().
//
// E.g.:
// cache_test(function(cache) {
// // Do something with |cache|, which is a Cache object.
// }, "Some Cache test");
function cache_test(test_function, description) {
promise_test(function(test) {
return create_temporary_cache(test)
.then(test_function);
}, description);
}

Просмотреть файл

@ -1,163 +0,0 @@
/*
* testharness-helpers contains various useful extensions to testharness.js to
* allow them to be used across multiple tests before they have been
* upstreamed. This file is intended to be usable from both document and worker
* environments, so code should for example not rely on the DOM.
*/
// Returns a promise that fulfills after the provided |promise| is fulfilled.
// The |test| succeeds only if |promise| rejects with an exception matching
// |code|. Accepted values for |code| follow those accepted for assert_throws().
// The optional |description| describes the test being performed.
//
// E.g.:
// assert_promise_rejects(
// new Promise(...), // something that should throw an exception.
// 'NotFoundError',
// 'Should throw NotFoundError.');
//
// assert_promise_rejects(
// new Promise(...),
// new TypeError(),
// 'Should throw TypeError');
function assert_promise_rejects(promise, code, description) {
return promise.then(
function() {
throw 'assert_promise_rejects: ' + description + ' Promise did not reject.';
},
function(e) {
if (code !== undefined) {
assert_throws(code, function() { throw e; }, description);
}
});
}
// Asserts that two objects |actual| and |expected| are weakly equal under the
// following definition:
//
// |a| and |b| are weakly equal if any of the following are true:
// 1. If |a| is not an 'object', and |a| === |b|.
// 2. If |a| is an 'object', and all of the following are true:
// 2.1 |a.p| is weakly equal to |b.p| for all own properties |p| of |a|.
// 2.2 Every own property of |b| is an own property of |a|.
//
// This is a replacement for the the version of assert_object_equals() in
// testharness.js. The latter doesn't handle own properties correctly. I.e. if
// |a.p| is not an own property, it still requires that |b.p| be an own
// property.
//
// Note that |actual| must not contain cyclic references.
self.assert_object_equals = function(actual, expected, description) {
var object_stack = [];
function _is_equal(actual, expected, prefix) {
if (typeof actual !== 'object') {
assert_equals(actual, expected, prefix);
return;
}
assert_true(typeof expected === 'object', prefix);
assert_equals(object_stack.indexOf(actual), -1,
prefix + ' must not contain cyclic references.');
object_stack.push(actual);
Object.getOwnPropertyNames(expected).forEach(function(property) {
assert_own_property(actual, property, prefix);
_is_equal(actual[property], expected[property],
prefix + '.' + property);
});
Object.getOwnPropertyNames(actual).forEach(function(property) {
assert_own_property(expected, property, prefix);
});
object_stack.pop();
}
function _brand(object) {
return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1];
}
_is_equal(actual, expected,
(description ? description + ': ' : '') + _brand(expected));
};
// Equivalent to assert_in_array, but uses a weaker equivalence relation
// (assert_object_equals) than '==='.
function assert_object_in_array(actual, expected_array, description) {
assert_true(expected_array.some(function(element) {
try {
assert_object_equals(actual, element);
return true;
} catch (e) {
return false;
}
}), description);
}
// Assert that the two arrays |actual| and |expected| contain the same set of
// elements as determined by assert_object_equals. The order is not significant.
//
// |expected| is assumed to not contain any duplicates as determined by
// assert_object_equals().
function assert_array_equivalent(actual, expected, description) {
assert_true(Array.isArray(actual), description);
assert_equals(actual.length, expected.length, description);
expected.forEach(function(expected_element) {
// assert_in_array treats the first argument as being 'actual', and the
// second as being 'expected array'. We are switching them around because
// we want to be resilient against the |actual| array containing
// duplicates.
assert_object_in_array(expected_element, actual, description);
});
}
// Asserts that two arrays |actual| and |expected| contain the same set of
// elements as determined by assert_object_equals(). The corresponding elements
// must occupy corresponding indices in their respective arrays.
function assert_array_objects_equals(actual, expected, description) {
assert_true(Array.isArray(actual), description);
assert_equals(actual.length, expected.length, description);
actual.forEach(function(value, index) {
assert_object_equals(value, expected[index],
description + ' : object[' + index + ']');
});
}
// Asserts that |object| that is an instance of some interface has the attribute
// |attribute_name| following the conditions specified by WebIDL, but it's
// acceptable that the attribute |attribute_name| is an own property of the
// object because we're in the middle of moving the attribute to a prototype
// chain. Once we complete the transition to prototype chains,
// assert_will_be_idl_attribute must be replaced with assert_idl_attribute
// defined in testharness.js.
//
// FIXME: Remove assert_will_be_idl_attribute once we complete the transition
// of moving the DOM attributes to prototype chains. (http://crbug.com/43394)
function assert_will_be_idl_attribute(object, attribute_name, description) {
assert_true(typeof object === "object", description);
assert_true("hasOwnProperty" in object, description);
// Do not test if |attribute_name| is not an own property because
// |attribute_name| is in the middle of the transition to a prototype
// chain. (http://crbug.com/43394)
assert_true(attribute_name in object, description);
}
// Stringifies a DOM object. This function stringifies not only own properties
// but also DOM attributes which are on a prototype chain. Note that
// JSON.stringify only stringifies own properties.
function stringifyDOMObject(object)
{
function deepCopy(src) {
if (typeof src != "object")
return src;
var dst = Array.isArray(src) ? [] : {};
for (var property in src) {
dst[property] = deepCopy(src[property]);
}
return dst;
}
return JSON.stringify(deepCopy(object));
}

Просмотреть файл

@ -1,145 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
cache_test(function(cache) {
return assert_promise_rejects(
cache.add(),
new TypeError(),
'Cache.add should throw a TypeError when no arguments are given.');
}, 'Cache.add called with no arguments');
cache_test(function(cache) {
return cache.add('../resources/simple.txt')
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
});
}, 'Cache.add called with relative URL specified as a string');
cache_test(function(cache) {
return assert_promise_rejects(
cache.add('javascript://this-is-not-http-mmkay'),
'NetworkError',
'Cache.add should throw a NetworkError for non-HTTP/HTTPS URLs.');
}, 'Cache.add called with non-HTTP/HTTPS URL');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
return cache.add(request)
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
});
}, 'Cache.add called with Request object');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
return request.text()
.then(function() {
assert_false(request.bodyUsed);
})
.then(function() {
return cache.add(request);
});
}, 'Cache.add called with Request object with a used body');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt', {method: 'POST', body: 'Hello'});
return cache.add(request)
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
})
.then(function() {
return assert_promise_rejects(
cache.add(request),
new TypeError(),
'Cache.add should throw TypeError if same request is added twice.');
});
}, 'Cache.add called twice with the same Request object');
cache_test(function(cache) {
return cache.add('this-does-not-exist-please-dont-create-it')
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
});
}, 'Cache.add with request that results in a status of 404');
cache_test(function(cache) {
return cache.add('../resources/fetch-status.py?status=500')
.then(function(result) {
assert_equals(result, undefined,
'Cache.add should resolve with undefined on success.');
});
}, 'Cache.add with request that results in a status of 500');
cache_test(function(cache) {
return assert_promise_rejects(
cache.addAll(),
new TypeError(),
'Cache.addAll with no arguments should throw TypeError.');
}, 'Cache.addAll with no arguments');
cache_test(function(cache) {
// Assumes the existence of ../resources/simple.txt and ../resources/blank.html
var urls = ['../resources/simple.txt', undefined, '../resources/blank.html'];
return assert_promise_rejects(
cache.addAll(),
new TypeError(),
'Cache.addAll should throw TypeError for an undefined argument.');
}, 'Cache.addAll with a mix of valid and undefined arguments');
cache_test(function(cache) {
// Assumes the existence of ../resources/simple.txt and ../resources/blank.html
var urls = ['../resources/simple.txt', self.location.href, '../resources/blank.html'];
return cache.addAll(urls)
.then(function(result) {
assert_equals(result, undefined,
'Cache.addAll should resolve with undefined on ' +
'success.');
});
}, 'Cache.addAll with string URL arguments');
cache_test(function(cache) {
// Assumes the existence of ../resources/simple.txt and ../resources/blank.html
var urls = ['../resources/simple.txt', self.location.href, '../resources/blank.html'];
var requests = urls.map(function(url) {
return new Request(url);
});
return cache.addAll(requests)
.then(function(result) {
assert_equals(result, undefined,
'Cache.addAll should resolve with undefined on ' +
'success.');
});
}, 'Cache.addAll with Request arguments');
cache_test(function(cache) {
// Assumes that ../resources/simple.txt and ../resources/blank.html exist. The second
// resource does not.
var urls = ['../resources/simple.txt', 'this-resource-should-not-exist', '../resources/blank.html'];
var requests = urls.map(function(url) {
return new Request(url);
});
return cache.addAll(requests)
.then(function(result) {
assert_equals(result, undefined,
'Cache.addAll should resolve with undefined on ' +
'success.');
});
}, 'Cache.addAll with a mix of succeeding and failing requests');
cache_test(function(cache) {
var request = new Request('../resources/simple.txt');
return assert_promise_rejects(
cache.addAll([request, request]),
new TypeError(),
'Cache.addAll should throw TypeError if the same request is added ' +
'twice.');
}, 'Cache.addAll called with the same Request object specified twice');
done();

Просмотреть файл

@ -1,120 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
var test_url = 'https://example.com/foo';
// Construct a generic Request object. The URL is |test_url|. All other fields
// are defaults.
function new_test_request() {
return new Request(test_url);
}
// Construct a generic Response object.
function new_test_response() {
return new Response('Hello world!', { status: 200 });
}
cache_test(function(cache) {
return assert_promise_rejects(
cache.delete(),
new TypeError(),
'Cache.delete should reject with a TypeError when called with no ' +
'arguments.');
}, 'Cache.delete with no arguments');
cache_test(function(cache) {
return cache.put(new_test_request(), new_test_response())
.then(function() {
return cache.delete(test_url);
})
.then(function(result) {
assert_true(result,
'Cache.delete should resolve with "true" if an entry ' +
'was successfully deleted.');
return cache.match(test_url);
})
.then(function(result) {
assert_equals(result, undefined,
'Cache.delete should remove matching entries from cache.');
});
}, 'Cache.delete called with a string URL');
cache_test(function(cache) {
var request = new Request(test_url, { method: 'POST', body: 'Abc' });
return cache.put(request.clone(), new_test_response())
.then(function() {
return cache.delete(request);
})
.then(function(result) {
assert_true(result,
'Cache.delete should resolve with "true" if an entry ' +
'was successfully deleted.');
assert_false(request.bodyUsed,
'Cache.delete should not consume request body.');
});
}, 'Cache.delete called with a Request object');
cache_test(function(cache) {
var request = new Request(test_url, { method: 'POST', body: 'Abc' });
return cache.put(request.clone(), new_test_response())
.then(function() {
return request.text();
})
.then(function() {
assert_true(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#body-mixin] ' +
'Request.bodyUsed should be true after text() method ' +
'resolves.');
})
.then(function() {
return cache.delete(request);
})
.then(function(result) {
assert_true(result,
'Cache.delete should resolve with "true" if an entry ' +
'was successfully deleted.');
});
}, 'Cache.delete with a Request object containing used body');
cache_test(function(cache) {
return cache.delete(test_url)
.then(function(result) {
assert_false(result,
'Cache.delete should resolve with "false" if there ' +
'are no matching entries.');
});
}, 'Cache.delete with a non-existent entry');
var cache_entries = {
a: {
request: new Request('http://example.com/abc'),
response: new Response('')
},
b: {
request: new Request('http://example.com/b'),
response: new Response('')
},
a_with_query: {
request: new Request('http://example.com/abc?q=r'),
response: new Response('')
}
};
function prepopulated_cache_test(test_function, description) {
cache_test(function(cache) {
return Promise.all(Object.keys(cache_entries).map(function(k) {
return cache.put(cache_entries[k].request.clone(),
cache_entries[k].response.clone());
}))
.then(function() {
return test_function(cache);
});
}, description);
}
done();

Просмотреть файл

@ -1,501 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
// A set of Request/Response pairs to be used with prepopulated_cache_test().
var simple_entries = [
{
name: 'a',
request: new Request('http://example.com/a'),
response: new Response('')
},
{
name: 'b',
request: new Request('http://example.com/b'),
response: new Response('')
},
{
name: 'a_with_query',
request: new Request('http://example.com/a?q=r'),
response: new Response('')
},
{
name: 'A',
request: new Request('http://example.com/A'),
response: new Response('')
},
{
name: 'a_https',
request: new Request('https://example.com/a'),
response: new Response('')
},
{
name: 'a_org',
request: new Request('http://example.org/a'),
response: new Response('')
},
{
name: 'cat',
request: new Request('http://example.com/cat'),
response: new Response('')
},
{
name: 'catmandu',
request: new Request('http://example.com/catmandu'),
response: new Response('')
},
{
name: 'cat_num_lives',
request: new Request('http://example.com/cat?lives=9'),
response: new Response('')
},
{
name: 'cat_in_the_hat',
request: new Request('http://example.com/cat/in/the/hat'),
response: new Response('')
},
{
name: 'secret_cat',
request: new Request('http://tom:jerry@example.com/cat'),
response: new Response('')
},
{
name: 'top_secret_cat',
request: new Request('http://tom:j3rry@example.com/cat'),
response: new Response('')
}
];
// A set of Request/Response pairs to be used with prepopulated_cache_test().
// These contain a mix of test cases that use Vary headers.
var vary_entries = [
{
name: 'vary_cookie_is_cookie',
request: new Request('http://example.com/c',
{headers: {'Cookies': 'is-for-cookie'}}),
response: new Response('',
{headers: {'Vary': 'Cookies'}})
},
{
name: 'vary_cookie_is_good',
request: new Request('http://example.com/c',
{headers: {'Cookies': 'is-good-enough-for-me'}}),
response: new Response('',
{headers: {'Vary': 'Cookies'}})
},
{
name: 'vary_cookie_absent',
request: new Request('http://example.com/c'),
response: new Response('',
{headers: {'Vary': 'Cookies'}})
},
{
name: 'vary_wildcard',
request: new Request('http://example.com/c',
{headers: {'Cookies': 'x', 'X-Key': '1'}}),
response: new Response('',
{headers: {'Vary': '*'}})
}
];
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll('not-present-in-the-cache')
.then(function(result) {
assert_array_equivalent(
result, [],
'Cache.matchAll should resolve with an empty array on failure.');
});
}, 'Cache.matchAll with no matching entries');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match('not-present-in-the-cache')
.then(function(result) {
assert_equals(result, undefined,
'Cache.match failures should resolve with undefined.');
});
}, 'Cache.match with no matching entries');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.a.request.url)
.then(function(result) {
assert_array_objects_equals(result, [entries.a.response],
'Cache.matchAll should match by URL.');
});
}, 'Cache.matchAll with URL');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request.url)
.then(function(result) {
assert_object_equals(result, entries.a.response,
'Cache.match should match by URL.');
});
}, 'Cache.match with URL');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.a.request)
.then(function(result) {
assert_array_objects_equals(
result, [entries.a.response],
'Cache.matchAll should match by Request.');
});
}, 'Cache.matchAll with Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request)
.then(function(result) {
assert_object_equals(result, entries.a.response,
'Cache.match should match by Request.');
});
}, 'Cache.match with Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(new Request(entries.a.request.url))
.then(function(result) {
assert_array_objects_equals(
result, [entries.a.response],
'Cache.matchAll should match by Request.');
});
}, 'Cache.matchAll with new Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(new Request(entries.a.request.url))
.then(function(result) {
assert_object_equals(result, entries.a.response,
'Cache.match should match by Request.');
});
}, 'Cache.match with new Request');
cache_test(function(cache) {
var request = new Request('https://example.com/foo', {
method: 'POST',
body: 'Hello world!'
});
var response = new Response('Booyah!', {
status: 200,
headers: {'Content-Type': 'text/plain'}
});
return cache.put(request.clone(), response.clone())
.then(function() {
assert_false(
request.bodyUsed,
'[https://fetch.spec.whatwg.org/#concept-body-used-flag] ' +
'Request.bodyUsed flag should be initially false.');
})
.then(function() {
return cache.match(request);
})
.then(function(result) {
assert_false(request.bodyUsed,
'Cache.match should not consume Request body.');
});
}, 'Cache.match with Request containing non-empty body');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.a.request,
{ignoreSearch: true})
.then(function(result) {
assert_array_equivalent(
result,
[
entries.a.response,
entries.a_with_query.response
],
'Cache.matchAll with ignoreSearch should ignore the ' +
'search parameters of cached request.');
});
},
'Cache.matchAll with ignoreSearch option (request with no search ' +
'parameters)');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request,
{ignoreSearch: true})
.then(function(result) {
assert_object_in_array(
result,
[
entries.a.response,
entries.a_with_query.response
],
'Cache.match with ignoreSearch should ignore the ' +
'search parameters of cached request.');
});
},
'Cache.match with ignoreSearch option (request with no search ' +
'parameters)');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.a_with_query.request,
{ignoreSearch: true})
.then(function(result) {
assert_array_equivalent(
result,
[
entries.a.response,
entries.a_with_query.response
],
'Cache.matchAll with ignoreSearch should ignore the ' +
'search parameters of request.');
});
},
'Cache.matchAll with ignoreSearch option (request with search parameter)');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a_with_query.request,
{ignoreSearch: true})
.then(function(result) {
assert_object_in_array(
result,
[
entries.a.response,
entries.a_with_query.response
],
'Cache.match with ignoreSearch should ignore the ' +
'search parameters of request.');
});
},
'Cache.match with ignoreSearch option (request with search parameter)');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.cat.request.url + '#mouse')
.then(function(result) {
assert_array_equivalent(
result,
[
entries.cat.response,
],
'Cache.matchAll should ignore URL fragment.');
});
}, 'Cache.matchAll with URL containing fragment');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.cat.request.url + '#mouse')
.then(function(result) {
assert_object_equals(result, entries.cat.response,
'Cache.match should ignore URL fragment.');
});
}, 'Cache.match with URL containing fragment');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll('http')
.then(function(result) {
assert_array_equivalent(
result, [],
'Cache.matchAll should treat query as a URL and not ' +
'just a string fragment.');
});
}, 'Cache.matchAll with string fragment "http" as query');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match('http')
.then(function(result) {
assert_equals(
result, undefined,
'Cache.match should treat query as a URL and not ' +
'just a string fragment.');
});
}, 'Cache.match with string fragment "http" as query');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.matchAll(entries.secret_cat.request.url)
.then(function(result) {
assert_array_equivalent(
result, [entries.secret_cat.response],
'Cache.matchAll should not ignore embedded credentials');
});
}, 'Cache.matchAll with URL containing credentials');
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.secret_cat.request.url)
.then(function(result) {
assert_object_equals(
result, entries.secret_cat.response,
'Cache.match should not ignore embedded credentials');
});
}, 'Cache.match with URL containing credentials');
prepopulated_cache_test(vary_entries, function(cache, entries) {
return cache.matchAll('http://example.com/c')
.then(function(result) {
assert_array_equivalent(
result,
[
entries.vary_wildcard.response,
entries.vary_cookie_absent.response
],
'Cache.matchAll should exclude matches if a vary header is ' +
'missing in the query request, but is present in the cached ' +
'request.');
})
.then(function() {
return cache.matchAll(
new Request('http://example.com/c',
{headers: {'Cookies': 'none-of-the-above'}}));
})
.then(function(result) {
assert_array_equivalent(
result,
[
entries.vary_wildcard.response
],
'Cache.matchAll should exclude matches if a vary header is ' +
'missing in the cached request, but is present in the query ' +
'request.');
})
.then(function() {
return cache.matchAll(
new Request('http://example.com/c',
{headers: {'Cookies': 'is-for-cookie'}}));
})
.then(function(result) {
assert_array_equivalent(
result,
[entries.vary_cookie_is_cookie.response],
'Cache.matchAll should match the entire header if a vary header ' +
'is present in both the query and cached requests.');
});
}, 'Cache.matchAll with responses containing "Vary" header');
prepopulated_cache_test(vary_entries, function(cache, entries) {
return cache.match('http://example.com/c')
.then(function(result) {
assert_object_in_array(
result,
[
entries.vary_wildcard.response,
entries.vary_cookie_absent.response
],
'Cache.match should honor "Vary" header.');
});
}, 'Cache.match with responses containing "Vary" header');
prepopulated_cache_test(vary_entries, function(cache, entries) {
return cache.matchAll('http://example.com/c',
{ignoreVary: true})
.then(function(result) {
assert_array_equivalent(
result,
[
entries.vary_cookie_is_cookie.response,
entries.vary_cookie_is_good.response,
entries.vary_cookie_absent.response,
entries.vary_wildcard.response
],
'Cache.matchAll should honor "ignoreVary" parameter.');
});
}, 'Cache.matchAll with "ignoreVary" parameter');
cache_test(function(cache) {
var request = new Request('http://example.com');
var response;
var request_url = new URL('../resources/simple.txt', location.href).href;
return fetch(request_url)
.then(function(fetch_result) {
response = fetch_result;
assert_equals(
response.url, request_url,
'[https://fetch.spec.whatwg.org/#dom-response-url] ' +
'Reponse.url should return the URL of the response.');
return cache.put(request, response.clone());
})
.then(function() {
return cache.match(request.url);
})
.then(function(result) {
assert_object_equals(
result, response,
'Cache.match should return a Response object that has the same ' +
'properties as the stored response.');
return cache.match(response.url);
})
.then(function(result) {
assert_equals(
result, undefined,
'Cache.match should not match cache entry based on response URL.');
});
}, 'Cache.match with Request and Response objects with different URLs');
cache_test(function(cache) {
var request_url = new URL('../resources/simple.txt', location.href).href;
return fetch(request_url)
.then(function(fetch_result) {
return cache.put(new Request(request_url), fetch_result);
})
.then(function() {
return cache.match(request_url);
})
.then(function(result) {
return result.text();
})
.then(function(body_text) {
assert_equals(body_text, 'a simple text file\n',
'Cache.match should return a Response object with a ' +
'valid body.');
})
.then(function() {
return cache.match(request_url);
})
.then(function(result) {
return result.text();
})
.then(function(body_text) {
assert_equals(body_text, 'a simple text file\n',
'Cache.match should return a Response object with a ' +
'valid body each time it is called.');
});
}, 'Cache.match invoked multiple times for the same Request/Response');
// Helpers ---
// Run |test_function| with a Cache object as its only parameter. Prior to the
// call, the Cache is populated by cache entries from |entries|. The latter is
// expected to be an Object mapping arbitrary keys to objects of the form
// {request: <Request object>, response: <Response object>}. There's no
// guarantee on the order in which entries will be added to the cache.
//
// |test_function| should return a Promise that can be used with promise_test.
function prepopulated_cache_test(entries, test_function, description) {
cache_test(function(cache) {
var p = Promise.resolve();
var hash = {};
entries.forEach(function(entry) {
p = p.then(function() {
return cache.put(entry.request.clone(),
entry.response.clone())
.catch(function(e) {
assert_unreached('Test setup failed for entry ' +
entry.name + ': ' + e);
});
});
hash[entry.name] = entry;
});
p = p.then(function() {
assert_equals(Object.keys(hash).length, entries.length);
});
return p.then(function() {
return test_function(cache, hash);
});
}, description);
}
done();

Просмотреть файл

@ -1,324 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
var test_url = 'https://example.com/foo';
var test_body = 'Hello world!';
cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response(test_body);
return cache.put(request, response)
.then(function(result) {
assert_equals(result, undefined,
'Cache.put should resolve with undefined on success.');
});
}, 'Cache.put called with simple Request and Response');
cache_test(function(cache) {
var test_url = new URL('../resources/simple.txt', location.href).href;
var request = new Request(test_url);
var response;
return fetch(test_url)
.then(function(fetch_result) {
response = fetch_result.clone();
return cache.put(request, fetch_result);
})
.then(function() {
return cache.match(test_url);
})
.then(function(result) {
assert_object_equals(result, response,
'Cache.put should update the cache with ' +
'new request and response.');
return result.text();
})
.then(function(body) {
assert_equals(body, 'a simple text file\n',
'Cache.put should store response body.');
});
}, 'Cache.put called with Request and Response from fetch()');
cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response(test_body);
assert_false(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Request.bodyUsed should be initially false.');
return cache.put(request, response)
.then(function() {
assert_false(request.bodyUsed,
'Cache.put should not mark empty request\'s body used');
});
}, 'Cache.put with Request without a body');
cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response();
assert_false(response.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Response.bodyUsed should be initially false.');
return cache.put(request, response)
.then(function() {
assert_false(response.bodyUsed,
'Cache.put should not mark empty response\'s body used');
});
}, 'Cache.put with Response without a body');
cache_test(function(cache) {
var request = new Request(test_url, {
method: 'POST',
body: 'Hello'
});
var response = new Response(test_body);
assert_false(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Request.bodyUsed should be initially false.');
return cache.put(request, response.clone())
.then(function() {
assert_true(request.bodyUsed,
'Cache.put should consume Request body.');
})
.then(function() {
return cache.match(request);
})
.then(function(result) {
assert_object_equals(result, response,
'Cache.put should store response body.');
});
}, 'Cache.put with Request containing a body');
cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response(test_body);
return cache.put(request, response.clone())
.then(function() {
return cache.match(test_url);
})
.then(function(result) {
assert_object_equals(result, response,
'Cache.put should update the cache with ' +
'new Request and Response.');
});
}, 'Cache.put with a Response containing an empty URL');
cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response('', {
status: 200,
headers: [['Content-Type', 'text/plain']]
});
return cache.put(request, response)
.then(function() {
return cache.match(test_url);
})
.then(function(result) {
assert_equals(result.status, 200, 'Cache.put should store status.');
assert_equals(result.headers.get('Content-Type'), 'text/plain',
'Cache.put should store headers.');
return result.text();
})
.then(function(body) {
assert_equals(body, '',
'Cache.put should store response body.');
});
}, 'Cache.put with an empty response body');
cache_test(function(cache) {
var test_url = new URL('../resources/fetch-status.py?status=500', location.href).href;
var request = new Request(test_url);
var response;
return fetch(test_url)
.then(function(fetch_result) {
assert_equals(fetch_result.status, 500,
'Test framework error: The status code should be 500.');
response = fetch_result.clone();
return cache.put(request, fetch_result);
})
.then(function() {
return cache.match(test_url);
})
.then(function(result) {
assert_object_equals(result, response,
'Cache.put should update the cache with ' +
'new request and response.');
return result.text();
})
.then(function(body) {
assert_equals(body, '',
'Cache.put should store response body.');
});
}, 'Cache.put with HTTP 500 response');
cache_test(function(cache) {
var alternate_response_body = 'New body';
var alternate_response = new Response(alternate_response_body,
{ statusText: 'New status' });
return cache.put(new Request(test_url),
new Response('Old body', { statusText: 'Old status' }))
.then(function() {
return cache.put(new Request(test_url), alternate_response.clone());
})
.then(function() {
return cache.match(test_url);
})
.then(function(result) {
assert_object_equals(result, alternate_response,
'Cache.put should replace existing ' +
'response with new response.');
return result.text();
})
.then(function(body) {
assert_equals(body, alternate_response_body,
'Cache put should store new response body.');
});
}, 'Cache.put called twice with matching Requests and different Responses');
cache_test(function(cache) {
var first_url = test_url;
var second_url = first_url + '#(O_o)';
var alternate_response_body = 'New body';
var alternate_response = new Response(alternate_response_body,
{ statusText: 'New status' });
return cache.put(new Request(first_url),
new Response('Old body', { statusText: 'Old status' }))
.then(function() {
return cache.put(new Request(second_url), alternate_response.clone());
})
.then(function() {
return cache.match(test_url);
})
.then(function(result) {
assert_object_equals(result, alternate_response,
'Cache.put should replace existing ' +
'response with new response.');
return result.text();
})
.then(function(body) {
assert_equals(body, alternate_response_body,
'Cache put should store new response body.');
});
}, 'Cache.put called twice with request URLs that differ only by a fragment');
cache_test(function(cache) {
var entries = {
dark: {
url: 'http://darkhelmet:12345@example.com/spaceballs',
body: 'Moranis'
},
skroob: {
url: 'http://skroob:12345@example.com/spaceballs',
body: 'Brooks'
},
control: {
url: 'http://example.com/spaceballs',
body: 'v(o.o)v'
}
};
return Promise.all(Object.keys(entries).map(function(key) {
return cache.put(new Request(entries[key].url),
new Response(entries[key].body));
}))
.then(function() {
return Promise.all(Object.keys(entries).map(function(key) {
return cache.match(entries[key].url)
.then(function(result) {
return result.text();
})
.then(function(body) {
assert_equals(body, entries[key].body,
'Cache put should store response body.');
});
}));
});
}, 'Cache.put with request URLs containing embedded credentials');
cache_test(function(cache) {
var url = 'http://example.com/foo';
return cache.put(url, new Response('some body'))
.then(function() { return cache.match(url); })
.then(function(response) { return response.text(); })
.then(function(body) {
assert_equals(body, 'some body',
'Cache.put should accept a string as request.');
});
}, 'Cache.put with a string request');
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new Request(test_url), 'Hello world!'),
new TypeError(),
'Cache.put should only accept a Response object as the response.');
}, 'Cache.put with an invalid response');
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new Request('file:///etc/passwd'),
new Response(test_body)),
new TypeError(),
'Cache.put should reject non-HTTP/HTTPS requests with a TypeError.');
}, 'Cache.put with a non-HTTP/HTTPS request');
cache_test(function(cache) {
var response = new Response(test_body);
return cache.put(new Request('relative-url'), response.clone())
.then(function() {
return cache.match(new URL('relative-url', location.href).href);
})
.then(function(result) {
assert_object_equals(result, response,
'Cache.put should accept a relative URL ' +
'as the request.');
});
}, 'Cache.put with a relative URL');
cache_test(function(cache) {
var request = new Request('http://example.com/foo', { method: 'HEAD' });
return assert_promise_rejects(
cache.put(request, new Response(test_body)),
new TypeError(),
'Cache.put should throw a TypeError for non-GET requests.');
}, 'Cache.put with a non-GET request');
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new Request(test_url), null),
new TypeError(),
'Cache.put should throw a TypeError for a null response.');
}, 'Cache.put with a null response');
cache_test(function(cache) {
var request = new Request(test_url, {method: 'POST', body: test_body});
assert_false(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Request.bodyUsed should be initially false.');
var copy = new Request(request);
assert_true(request.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-request] ' +
'Request constructor should set input\'s used flag.');
return assert_promise_rejects(
cache.put(request, new Response(test_body)),
new TypeError(),
'Cache.put should throw a TypeError for a request with used body.');
}, 'Cache.put with a used request body');
cache_test(function(cache) {
var response = new Response(test_body);
assert_false(response.bodyUsed,
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Response.bodyUsed should be initially false.');
return response.text().then(function() {
assert_false(
response.bodyUsed,
'[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' +
'The text() method should not set "body passed" flag.');
return cache.put(new Request(test_url), response);
});
}, 'Cache.put with a used response body');
done();

Просмотреть файл

@ -1,36 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
var test_cache_list =
['', 'example', 'Another cache name', 'A', 'a', 'ex ample'];
promise_test(function(test) {
return self.caches.keys()
.then(function(keys) {
assert_true(Array.isArray(keys),
'CacheStorage.keys should return an Array.');
return Promise.all(keys.map(function(key) {
return self.caches.delete(key);
}));
})
.then(function() {
return Promise.all(test_cache_list.map(function(key) {
return self.caches.open(key);
}));
})
.then(function() { return self.caches.keys(); })
.then(function(keys) {
assert_true(Array.isArray(keys),
'CacheStorage.keys should return an Array.');
assert_array_equals(keys,
test_cache_list,
'CacheStorage.keys should only return ' +
'existing caches.');
});
}, 'CacheStorage keys');
done();

Просмотреть файл

@ -1,123 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
(function() {
var next_index = 1;
// Returns a transaction (request, response, and url) for a unique URL.
function create_unique_transaction(test) {
var uniquifier = String(next_index++);
var url = 'http://example.com/' + uniquifier;
return {
request: new Request(url),
response: new Response('hello'),
url: url
};
}
self.create_unique_transaction = create_unique_transaction;
})();
cache_test(function(cache) {
var transaction = create_unique_transaction();
return cache.put(transaction.request.clone(), transaction.response.clone())
.then(function() {
return self.caches.match(transaction.request);
})
.then(function(response) {
assert_object_equals(response, transaction.response,
'The response should not have changed.');
});
}, 'CacheStorageMatch with no cache name provided');
cache_test(function(cache) {
var transaction = create_unique_transaction();
var test_cache_list = ['a', 'b', 'c'];
return cache.put(transaction.request.clone(), transaction.response.clone())
.then(function() {
return Promise.all(test_cache_list.map(function(key) {
return self.caches.open(key);
}));
})
.then(function() {
return self.caches.match(transaction.request);
})
.then(function(response) {
assert_object_equals(response, transaction.response,
'The response should not have changed.');
});
}, 'CacheStorageMatch from one of many caches');
promise_test(function(test) {
var transaction = create_unique_transaction();
var test_cache_list = ['x', 'y', 'z'];
return Promise.all(test_cache_list.map(function(key) {
return self.caches.open(key);
}))
.then(function() { return caches.open('x'); })
.then(function(cache) {
return cache.put(transaction.request.clone(),
transaction.response.clone());
})
.then(function() {
return self.caches.match(transaction.request, {cacheName: 'x'});
})
.then(function(response) {
assert_object_equals(response, transaction.response,
'The response should not have changed.');
})
.then(function() {
return self.caches.match(transaction.request, {cacheName: 'y'});
})
.then(function(response) {
assert_equals(response, undefined,
'Cache y should not have a response for the request.');
});
}, 'CacheStorageMatch from one of many caches by name');
cache_test(function(cache) {
var transaction = create_unique_transaction();
return cache.put(transaction.url, transaction.response.clone())
.then(function() {
return self.caches.match(transaction.request);
})
.then(function(response) {
assert_object_equals(response, transaction.response,
'The response should not have changed.');
});
}, 'CacheStorageMatch a string request');
promise_test(function(test) {
var transaction = create_unique_transaction();
return self.caches.match(transaction.request)
.then(function(response) {
assert_equals(response, undefined,
'The response should not be found.');
})
}, 'CacheStorageMatch with no cached entry');
promise_test(function(test) {
var transaction = create_unique_transaction();
return self.caches.has('foo')
.then(function(has_foo) {
assert_false(has_foo, "The cache should not exist.");
return self.caches.match(transaction.request, {cacheName: 'foo'});
})
.then(function(response) {
assert_equals(response, undefined,
'The response should not be found.');
return self.caches.has('foo');
})
.then(function(has_foo) {
assert_false(has_foo, "The cache should still not exist.");
})
}, 'CacheStorageMatch with no caches available but name provided');
done();

Просмотреть файл

@ -1,192 +0,0 @@
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('../resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
promise_test(function(t) {
var cache_name = 'cache-storage/foo';
return self.caches.delete(cache_name)
.then(function() {
return self.caches.open(cache_name);
})
.then(function(cache) {
assert_true(cache instanceof Cache,
'CacheStorage.open should return a Cache.');
});
}, 'CacheStorage.open');
promise_test(function(t) {
// Note that this test may collide with other tests running in the same
// origin that also uses an empty cache name.
var cache_name = '';
return self.caches.delete(cache_name)
.then(function() {
return self.caches.open(cache_name);
})
.then(function(cache) {
assert_true(cache instanceof Cache,
'CacheStorage.open should accept an empty name.');
});
}, 'CacheStorage.open with an empty name');
promise_test(function(t) {
return assert_promise_rejects(
self.caches.open(),
new TypeError(),
'CacheStorage.open should throw TypeError if called with no arguments.');
}, 'CacheStorage.open with no arguments');
promise_test(function(t) {
var test_cases = [
{
name: 'cache-storage/lowercase',
should_not_match:
[
'cache-storage/Lowercase',
' cache-storage/lowercase',
'cache-storage/lowercase '
]
},
{
name: 'cache-storage/has a space',
should_not_match:
[
'cache-storage/has'
]
},
{
name: 'cache-storage/has\000_in_the_name',
should_not_match:
[
'cache-storage/has',
'cache-storage/has_in_the_name'
]
}
];
return Promise.all(test_cases.map(function(testcase) {
var cache_name = testcase.name;
return self.caches.delete(cache_name)
.then(function() {
return self.caches.open(cache_name);
})
.then(function() {
return self.caches.has(cache_name);
})
.then(function(result) {
assert_true(result,
'CacheStorage.has should return true for existing ' +
'cache.');
})
.then(function() {
return Promise.all(
testcase.should_not_match.map(function(cache_name) {
return self.caches.has(cache_name)
.then(function(result) {
assert_false(result,
'CacheStorage.has should only perform ' +
'exact matches on cache names.');
});
}));
})
.then(function() {
return self.caches.delete(cache_name);
});
}));
}, 'CacheStorage.has with existing cache');
promise_test(function(t) {
return self.caches.has('cheezburger')
.then(function(result) {
assert_false(result,
'CacheStorage.has should return false for ' +
'nonexistent cache.');
});
}, 'CacheStorage.has with nonexistent cache');
promise_test(function(t) {
var cache_name = 'cache-storage/open';
var cache;
return self.caches.delete(cache_name)
.then(function() {
return self.caches.open(cache_name);
})
.then(function(result) {
cache = result;
})
.then(function() {
return self.caches.open(cache_name);
})
.then(function(result) {
assert_equals(result, cache,
'CacheStorage.open should return the named Cache ' +
'object if it exists.');
})
.then(function() {
return self.caches.open(cache_name);
})
.then(function(result) {
assert_equals(result, cache,
'CacheStorage.open should return the same ' +
'instance of an existing Cache object.');
});
}, 'CacheStorage.open with existing cache');
promise_test(function(t) {
var cache_name = 'cache-storage/delete';
return self.caches.delete(cache_name)
.then(function() {
return self.caches.open(cache_name);
})
.then(function() { return self.caches.delete(cache_name); })
.then(function(result) {
assert_true(result,
'CacheStorage.delete should return true after ' +
'deleting an existing cache.');
})
.then(function() { return self.caches.has(cache_name); })
.then(function(cache_exists) {
assert_false(cache_exists,
'CacheStorage.has should return false after ' +
'fulfillment of CacheStorage.delete promise.');
});
}, 'CacheStorage.delete with existing cache');
promise_test(function(t) {
return self.caches.delete('cheezburger')
.then(function(result) {
assert_false(result,
'CacheStorage.delete should return false for a ' +
'nonexistent cache.');
});
}, 'CacheStorage.delete with nonexistent cache');
promise_test(function(t) {
var bad_name = 'unpaired\uD800';
var converted_name = 'unpaired\uFFFD'; // Don't create cache with this name.
return self.caches.has(converted_name)
.then(function(cache_exists) {
assert_false(cache_exists,
'Test setup failure: cache should not exist');
})
.then(function() { return self.caches.open(bad_name); })
.then(function() { return self.caches.keys(); })
.then(function(keys) {
assert_true(keys.indexOf(bad_name) !== -1,
'keys should include cache with bad name');
})
.then(function() { return self.caches.has(bad_name); })
.then(function(cache_exists) {
assert_true(cache_exists,
'CacheStorage names should be not be converted.');
})
.then(function() { return self.caches.has(converted_name); })
.then(function(cache_exists) {
assert_false(cache_exists,
'CacheStorage names should be not be converted.');
});
}, 'CacheStorage names are DOMStrings not USVStrings');
done();

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>Cache.add and Cache.addAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-add.js');
</script>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>Cache.delete</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-delete.js');
</script>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>Cache.match and Cache.matchAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-match.js');
</script>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>Cache.put</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-put">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-put.js');
</script>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>CacheStorage.keys</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-storage-keys.js');
</script>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>CacheStorage.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-storage-match.js');
</script>

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<title>CacheStorage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-storage.js');
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: Cache.add and Cache.addAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-add.js"></script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: Cache.delete</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-delete.js"></script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: Cache.match and Cache.matchAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-match.js"></script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: Cache.put</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-put">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-put.js"></script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: CacheStorage.keys</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-storage-keys.js"></script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: CacheStorage.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-storage-match.js"></script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: CacheStorage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-storage.js"></script>

Просмотреть файл

@ -1,66 +0,0 @@
<!DOCTYPE html>
<title>Cache Storage: Verify access in sandboxed iframes</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script>
<script>
function load_iframe(src, sandbox) {
return new Promise(function(resolve, reject) {
var iframe = document.createElement('iframe');
iframe.onload = function() { resolve(iframe); };
iframe.sandbox = sandbox;
iframe.src = src;
document.documentElement.appendChild(iframe);
});
}
function wait_for_message(id) {
return new Promise(function(resolve) {
self.addEventListener('message', function listener(e) {
if (e.data.id === id) {
resolve(e.data);
self.removeEventListener(listener);
}
});
});
}
var counter = 0;
promise_test(function(t) {
return load_iframe('../resources/iframe.html',
'allow-scripts allow-same-origin')
.then(function(iframe) {
var id = ++counter;
iframe.contentWindow.postMessage({id: id}, '*');
return wait_for_message(id);
})
.then(function(message) {
assert_equals(
message.result, 'allowed',
'Access should be allowed if sandbox has allow-same-origin');
});
}, 'Sandboxed iframe with allow-same-origin is allowed access');
promise_test(function(t) {
return load_iframe('../resources/iframe.html',
'allow-scripts')
.then(function(iframe) {
var id = ++counter;
iframe.contentWindow.postMessage({id: id}, '*');
return wait_for_message(id);
})
.then(function(message) {
assert_equals(
message.result, 'denied',
'Access should be denied if sandbox lacks allow-same-origin');
assert_equals(message.name, 'SecurityError',
'Failure should be a SecurityError');
});
}, 'Sandboxed iframe without allow-same-origin is denied access');
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache.add and Cache.addAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-add.js'));
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache.delete</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-delete.js'));
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache.match and Cache.matchAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-match.js'));
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>Cache.put</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-put">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-put.js'));
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>CacheStorage.keys</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-storage-keys.js'));
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>CacheStorage.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-storage-match.js'));
</script>

Просмотреть файл

@ -1,8 +0,0 @@
<!DOCTYPE html>
<title>CacheStorage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-storage.js'));
</script>

Просмотреть файл

@ -1,222 +0,0 @@
// Adapter for testharness.js-style tests with Service Workers
function service_worker_unregister_and_register(test, url, scope) {
if (!scope || scope.length == 0)
return Promise.reject(new Error('tests must define a scope'));
var options = { scope: scope };
return service_worker_unregister(test, scope)
.then(function() {
return navigator.serviceWorker.register(url, options);
})
.catch(unreached_rejection(test,
'unregister and register should not fail'));
}
function service_worker_unregister(test, documentUrl) {
return navigator.serviceWorker.getRegistration(documentUrl)
.then(function(registration) {
if (registration)
return registration.unregister();
})
.catch(unreached_rejection(test, 'unregister should not fail'));
}
function service_worker_unregister_and_done(test, scope) {
return service_worker_unregister(test, scope)
.then(test.done.bind(test));
}
function unreached_fulfillment(test, prefix) {
return test.step_func(function(result) {
var error_prefix = prefix || 'unexpected fulfillment';
assert_unreached(error_prefix + ': ' + result);
});
}
// Rejection-specific helper that provides more details
function unreached_rejection(test, prefix) {
return test.step_func(function(error) {
var reason = error.message || error.name || error;
var error_prefix = prefix || 'unexpected rejection';
assert_unreached(error_prefix + ': ' + reason);
});
}
// Adds an iframe to the document and returns a promise that resolves to the
// iframe when it finishes loading. The caller is responsible for removing the
// iframe later if needed.
function with_iframe(url) {
return new Promise(function(resolve) {
var frame = document.createElement('iframe');
frame.src = url;
frame.onload = function() { resolve(frame); };
document.body.appendChild(frame);
});
}
function normalizeURL(url) {
return new URL(url, self.location).toString().replace(/#.*$/, '');
}
function wait_for_update(test, registration) {
if (!registration || registration.unregister == undefined) {
return Promise.reject(new Error(
'wait_for_update must be passed a ServiceWorkerRegistration'));
}
return new Promise(test.step_func(function(resolve) {
registration.addEventListener('updatefound', test.step_func(function() {
resolve(registration.installing);
}));
}));
}
function wait_for_state(test, worker, state) {
if (!worker || worker.state == undefined) {
return Promise.reject(new Error(
'wait_for_state must be passed a ServiceWorker'));
}
if (worker.state === state)
return Promise.resolve(state);
if (state === 'installing') {
switch (worker.state) {
case 'installed':
case 'activating':
case 'activated':
case 'redundant':
return Promise.reject(new Error(
'worker is ' + worker.state + ' but waiting for ' + state));
}
}
if (state === 'installed') {
switch (worker.state) {
case 'activating':
case 'activated':
case 'redundant':
return Promise.reject(new Error(
'worker is ' + worker.state + ' but waiting for ' + state));
}
}
if (state === 'activating') {
switch (worker.state) {
case 'activated':
case 'redundant':
return Promise.reject(new Error(
'worker is ' + worker.state + ' but waiting for ' + state));
}
}
if (state === 'activated') {
switch (worker.state) {
case 'redundant':
return Promise.reject(new Error(
'worker is ' + worker.state + ' but waiting for ' + state));
}
}
return new Promise(test.step_func(function(resolve) {
worker.addEventListener('statechange', test.step_func(function() {
if (worker.state === state)
resolve(state);
}));
}));
}
// Declare a test that runs entirely in the ServiceWorkerGlobalScope. The |url|
// is the service worker script URL. This function:
// - Instantiates a new test with the description specified in |description|.
// The test will succeed if the specified service worker can be successfully
// registered and installed.
// - Creates a new ServiceWorker registration with a scope unique to the current
// document URL. Note that this doesn't allow more than one
// service_worker_test() to be run from the same document.
// - Waits for the new worker to begin installing.
// - Imports tests results from tests running inside the ServiceWorker.
function service_worker_test(url, description) {
// If the document URL is https://example.com/document and the script URL is
// https://example.com/script/worker.js, then the scope would be
// https://example.com/script/scope/document.
var scope = new URL('scope' + window.location.pathname,
new URL(url, window.location)).toString();
promise_test(function(test) {
return service_worker_unregister_and_register(test, url, scope)
.then(function(registration) {
add_completion_callback(function() {
registration.unregister();
});
return wait_for_update(test, registration)
.then(function(worker) {
return fetch_tests_from_worker(worker);
});
});
}, description);
}
function get_host_info() {
var ORIGINAL_HOST = '127.0.0.1';
var REMOTE_HOST = 'localhost';
var UNAUTHENTICATED_HOST = 'example.test';
var HTTP_PORT = 8000;
var HTTPS_PORT = 8443;
try {
// In W3C test, we can get the hostname and port number in config.json
// using wptserve's built-in pipe.
// http://wptserve.readthedocs.org/en/latest/pipes.html#built-in-pipes
HTTP_PORT = eval('{{ports[http][0]}}');
HTTPS_PORT = eval('{{ports[https][0]}}');
ORIGINAL_HOST = eval('\'{{host}}\'');
REMOTE_HOST = 'www1.' + ORIGINAL_HOST;
} catch (e) {
}
return {
HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT,
HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT,
HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT,
HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT,
UNAUTHENTICATED_ORIGIN: 'http://' + UNAUTHENTICATED_HOST + ':' + HTTP_PORT
};
}
function base_path() {
return location.pathname.replace(/\/[^\/]*$/, '/');
}
function test_login(test, origin, username, password, cookie) {
return new Promise(function(resolve, reject) {
with_iframe(
origin +
'/serviceworker/resources/fetch-access-control-login.html')
.then(test.step_func(function(frame) {
var channel = new MessageChannel();
channel.port1.onmessage = test.step_func(function() {
frame.remove();
resolve();
});
frame.contentWindow.postMessage(
{username: username, password: password, cookie: cookie},
origin, [channel.port2]);
}));
});
}
function login(test) {
return test_login(test, 'http://127.0.0.1:8000',
'username1', 'password1', 'cookie1')
.then(function() {
return test_login(test, 'http://localhost:8000',
'username2', 'password2', 'cookie2');
});
}
function login_https(test) {
return test_login(test, 'https://127.0.0.1:8443',
'username1s', 'password1s', 'cookie1')
.then(function() {
return test_login(test, 'https://localhost:8443',
'username2s', 'password2s', 'cookie2');
});
}

Просмотреть файл

@ -1,204 +0,0 @@
import os
import re
import shutil
import glob
import tempfile
import sys
from collections import defaultdict
here = os.path.abspath(os.path.split(__file__)[0])
def get_extra_files(chromium_root):
return [(os.path.join(chromium_root, "LayoutTests", "http", "tests", "resources", "testharness-helpers.js"),
os.path.join("resources", "testharness-helpers.js"))]
resources_re = re.compile("/?(?:\.\./)*resources/(testharness(?:report)?)\.js")
def resources_path(line, depth):
return False, resources_re.sub(r"/resources/\1.js", line)
php_re = re.compile("\.php")
def python_to_php(line, depth):
return False, php_re.sub(".py", line)
abs_testharness_helpers_re = re.compile("([\"'])/resources/testharness-helpers.js")
testharness_helpers_re = re.compile("\.\./((?:\.\./)*)resources/testharness-helpers.js")
def testharness_helpers(line, depth):
if abs_testharness_helpers_re.findall(line):
return False, abs_testharness_helpers_re.sub(r"\1%sresources/testharness-helpers.js" % ("../" * (depth - 1)), line)
return False, testharness_helpers_re.sub(r"\1resources/testharness-helpers.js", line)
serviceworker_path_re = re.compile("/serviceworker/")
def service_worker_path(line, depth):
return False, serviceworker_path_re.sub("/service-workers/", line)
localhost_re = re.compile("localhost")
alt_host_re = re.compile("127\.0\.0\.1")
port_http_re = re.compile("8000")
port_https_re = re.compile("8000")
def server_names(line, depth):
line, count_0 = localhost_re.subn("{{host}}", line)
line, count_1 = alt_host_re.subn("{{domains[www]}}", line)
line, count_2 = port_http_re.subn("{{ports[http][0]}}", line)
line, count_3 = port_https_re.subn("{{ports[https][0]}}", line)
count = count_0 + count_1 + count_2 + count_3
return bool(count), line
def source_paths(chromium_root):
for dirpath, dirnames, filenames in os.walk(chromium_root):
if "chromium" in dirnames:
dirnames.remove("chromium")
for filename in filenames:
if filename.endswith("-expected.txt") or filename.endswith(".php"):
continue
yield os.path.relpath(os.path.join(dirpath, filename), chromium_root)
def do_subs(path, line):
depth = len(os.path.split(os.path.sep))
subs = [resources_path, python_to_php, testharness_helpers, service_worker_path, server_names]
file_is_template = False
for sub in subs:
added_template, line = sub(line, depth)
if added_template:
file_is_template = True
return file_is_template, line
def get_head(git):
return git("rev-parse", "HEAD")
def get_changes(git, path, old, new):
data = git("diff", "--name-status", "-z", "--no-renames", "%s..%s" % (old, new), "--", path)
items = data.split("\0")
rv = defaultdict(list)
for status, path in items:
rv[status].append(path)
return rv
def copy(src_path, out_dir, rel_path):
dest = os.path.normpath(os.path.join(out_dir, rel_path))
dest_dir = os.path.split(dest)[0]
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
shutil.copy2(src_path, dest)
def copy_local_files(local_files, out_root, tmp_dir):
for path in local_files:
rel_path = os.path.relpath(path, out_root)
copy(path, tmp_dir, rel_path)
def copy_extra_files(chromium_root, tmp_dir):
for in_path, rel_path in get_extra_files(chromium_root):
copy(in_path, tmp_dir, rel_path)
def sub_changed_filenames(filename_changes, f):
rv = []
for line in f:
for in_name, out_name in filename_changes.iteritems():
line = line.replace(in_name, out_name)
rv.append(line)
return "".join(rv)
testharness_re = re.compile("<script[^>]*src=[\"']?/resources/testharness.js[\"' ][^>]*>")
def is_top_level_test(path, data):
if os.path.splitext(path)[1] != ".html":
return False
for line in data:
if testharness_re.findall(line):
return True
return False
def add_suffix(path, suffix):
root, ext = os.path.splitext(path)
return root + ".%s" % suffix + ext
def main():
if "--cache-tests" in sys.argv:
sw_path = os.path.join("LayoutTests", "http", "tests", "cachestorage")
out_root = os.path.abspath(os.path.join(here, "..", "cache-storage"))
elif "--sw-tests" in sys.argv:
sw_path = os.path.join("LayoutTests", "http", "tests", "serviceworkers")
out_root = os.path.abspath(os.path.join(here, "..", "service-worker"))
else:
raise ValueError("Must supply either --cache-tests or --sw-tests")
chromium_root = os.path.abspath(sys.argv[1])
work_path = tempfile.mkdtemp()
test_path = os.path.join(chromium_root, sw_path)
local_files = glob.glob(os.path.normpath(os.path.join(here, "..", "resources", "*.py")))
if not os.path.exists(out_root):
os.mkdir(out_root)
copy_local_files(local_files, out_root, work_path)
copy_extra_files(chromium_root, work_path)
path_changes = {}
for path in source_paths(test_path):
out_path = os.path.join(work_path, path)
out_dir = os.path.dirname(out_path)
if not os.path.exists(out_dir):
os.makedirs(out_dir)
with open(os.path.join(test_path, path)) as in_f:
data = []
sub = False
for line in in_f:
sub_flag, output_line = do_subs(path, line)
data.append(output_line)
if sub_flag:
sub = True
is_test = is_top_level_test(out_path, data)
initial_path = out_path
if is_test:
path_1 = add_suffix(out_path, "https")
else:
path_1 = out_path
if sub:
path_2 = add_suffix(out_path, "sub")
else:
path_2 = path_1
if path_2 != initial_path:
path_changes[initial_path] = path_2
with open(path_2, "w") as out_f:
out_f.write("".join(data))
filename_changes = {}
for k, v in path_changes.iteritems():
if os.path.basename(k) in filename_changes:
print "Got duplicate name:" + os.path.basename(k)
filename_changes[os.path.basename(k)] = os.path.basename(v)
for path in source_paths(work_path):
full_path = os.path.join(work_path, path)
with open(full_path) as f:
data = sub_changed_filenames(filename_changes, f)
with open(full_path, "w") as f:
f.write(data)
for dirpath, dirnames, filenames in os.walk(work_path):
for filename in filenames:
in_path = os.path.join(dirpath, filename)
rel_path = os.path.relpath(in_path, work_path)
copy(in_path, out_root, rel_path)
if __name__ == "__main__":
main()

6
testing/web-platform/tests/tools/.gitignore поставляемый
Просмотреть файл

@ -1,6 +0,0 @@
*#
*.py[co]
*.sw[po]
*~
\#*

Просмотреть файл

@ -46,17 +46,6 @@ class SourceFile(object):
self.meta_flags = self.name.split(".")[1:]
def __getstate__(self):
# Remove computed properties if we pickle this class
rv = self.__dict__.copy()
cached_properties = rv.get("__cached_properties__", set())
for key in rv.keys():
if key in cached_properties:
del rv[key]
if "__cached_properties__" in rv:
del rv["__cached_properties__"]
return rv
def name_prefix(self, prefix):
"""Check if the filename starts with a given prefix

Просмотреть файл

@ -40,5 +40,4 @@ class cached_property(object):
if self.name not in obj.__dict__:
obj.__dict__[self.name] = self.func(obj)
obj.__dict__.setdefault("__cached_properties__", set()).add(self.name)
return obj.__dict__[self.name]

Просмотреть файл

@ -10,13 +10,13 @@
<div id="log"></div>
<script type="text/javascript">
var test = async_test();
var test = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(undefined) - INVALID_ACCESS_ERR is thrown");
var wsocket = CreateWebSocket(false, false, false);
var isOpenCalled = false;
wsocket.addEventListener('open', test.step_func(function (evt) {
wsocket.close(undefined);
assert_throws("INVALID_ACCESS_ERR", function () { wsocket.close(undefined) });
test.done();
}), true);
</script>

Просмотреть файл

@ -10,13 +10,13 @@
<div id="log"></div>
<script type="text/javascript">
var test = async_test();
var test = async_test("W3C WebSocket API - Create Secure WebSocket - Close the Connection - close(undefined) - INVALID_ACCESS_ERR is thrown");
var wsocket = CreateWebSocket(true, false, false);
var isOpenCalled = false;
wsocket.addEventListener('open', test.step_func(function (evt) {
wsocket.close(undefined);
assert_throws("INVALID_ACCESS_ERR", function () { wsocket.close(undefined) });
test.done();
}), true);
</script>

Просмотреть файл

@ -9,10 +9,8 @@ var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function(t) {
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
var obj = {handleEvent:this.unreached_func("handleEvent was called")};
ws[events[i]] = obj;
assert_equals(ws[events[i]], obj);
ws.dispatchEvent(new Event(events[i].substr(2)));
ws[events[i]] = {handleEvent:function(){}};
assert_equals(ws[events[i]], null);
}, events[i]);
};
</script>