From 8ea56eabaaf431d0e362532f433e5cac7408a447 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 21 Dec 2015 12:07:57 +0100 Subject: [PATCH] Update web-platform-tests to 887399d3d0a85d0e27a6688ae384459376adf7ca --- tests/wpt/metadata/MANIFEST.json | 29 ++--- .../metadata/dom/nodes/attributes.html.ini | 15 +++ tests/wpt/metadata/mozilla-sync | 2 +- .../XMLHttpRequest/open-url-worker-origin.htm | 1 - .../XMLHttpRequest/open-url-worker-simple.htm | 1 - .../xmlhttprequest-timeout-aborted.html | 1 - .../xmlhttprequest-timeout-abortedonmain.html | 1 - .../xmlhttprequest-timeout-overrides.html | 1 - ...lhttprequest-timeout-overridesexpires.html | 1 - .../xmlhttprequest-timeout-simple.html | 1 - .../xmlhttprequest-timeout-synconmain.html | 1 - .../xmlhttprequest-timeout-twice.html | 1 - ...xmlhttprequest-timeout-worker-aborted.html | 1 - ...lhttprequest-timeout-worker-overrides.html | 1 - ...quest-timeout-worker-overridesexpires.html | 1 - .../xmlhttprequest-timeout-worker-simple.html | 1 - ...tprequest-timeout-worker-synconworker.html | 1 - .../xmlhttprequest-timeout-worker-twice.html | 1 - .../cors/resources/cors-makeheader.py | 2 +- .../attached-callback-test.html | 1 + .../dom/nodes/attributes.html | 100 ++++++++++++++++++ .../wpt/web-platform-tests/hr-time/basic.html | 1 - .../hr-time/monotonic-clock.html | 1 - .../scroll-to-fragid/007.html | 9 +- .../creating_browsing_context_test_01.html | 4 +- .../navigation-timing/test_document_open.html | 1 - .../test_document_readiness_exist.html | 1 - .../test_navigation_type_backforward.html | 1 - .../test_navigation_type_reload.html | 1 - .../test_no_previous_document.html | 1 - .../test_performance_attributes_exist.html | 1 - ...erformance_attributes_exist_in_object.html | 1 - .../navigation-timing/test_readwrite.html | 1 - .../test_timing_attributes_order.html | 1 - .../test_timing_client_redirect.html | 1 - .../navigation-timing/test_timing_reload.html | 1 - .../test_unique_performance_objects.html | 1 - .../web-platform-tests/resources/docs/api.md | 10 +- .../web-platform-tests/tools/manifest/item.py | 10 +- .../tools/manifest/manifest.py | 14 +-- .../tools/manifest/utils.py | 6 ++ .../tools/wptserve/wptserve/handlers.py | 6 +- .../tools/wptserve/wptserve/pipes.py | 16 ++- .../tools/wptserve/wptserve/stash.py | 2 +- 44 files changed, 178 insertions(+), 77 deletions(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index fac39670859..8b59b3dd2f2 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -13271,10 +13271,6 @@ "path": "custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-move-element-test.html", "url": "/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-move-element-test.html" }, - { - "path": "custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html", - "url": "/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html" - }, { "path": "custom-elements/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-change-attribute-test.html", "url": "/custom-elements/custom-element-lifecycle/types-of-callbacks/attribute-changed-callback-change-attribute-test.html" @@ -15051,10 +15047,6 @@ "path": "html/browsers/browsing-the-web/scroll-to-fragid/006.html", "url": "/html/browsers/browsing-the-web/scroll-to-fragid/006.html" }, - { - "path": "html/browsers/browsing-the-web/scroll-to-fragid/007.html", - "url": "/html/browsers/browsing-the-web/scroll-to-fragid/007.html" - }, { "path": "html/browsers/browsing-the-web/unloading-documents/001.html", "url": "/html/browsers/browsing-the-web/unloading-documents/001.html" @@ -15495,10 +15487,6 @@ "path": "html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload.html", "url": "/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/close_unload.html" }, - { - "path": "html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html", - "url": "/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html" - }, { "path": "html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html", "url": "/html/browsers/the-window-object/garbage-collection-and-browsing-contexts/discard_iframe_history_1.html" @@ -28809,6 +28797,11 @@ "timeout": "long", "url": "/custom-elements/concepts/custom-elements-type-allowed-chars.html" }, + { + "path": "custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html", + "timeout": "long", + "url": "/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html" + }, { "path": "dom/nodes/Document-characterSet-normalization.html", "timeout": "long", @@ -28949,6 +28942,11 @@ "timeout": "long", "url": "/eventsource/shared-worker/eventsource-constructor-non-same-origin.htm" }, + { + "path": "html/browsers/browsing-the-web/scroll-to-fragid/007.html", + "timeout": "long", + "url": "/html/browsers/browsing-the-web/scroll-to-fragid/007.html" + }, { "path": "html/browsers/history/the-history-interface/007.html", "timeout": "long", @@ -28959,6 +28957,11 @@ "timeout": "long", "url": "/html/browsers/origin/cross-origin-objects/cross-origin-objects.sub.html" }, + { + "path": "html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html", + "timeout": "long", + "url": "/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/creating_browsing_context_test_01.html" + }, { "path": "html/dom/interfaces.html", "timeout": "long", @@ -35866,7 +35869,7 @@ } ] }, - "rev": "0bb3d73f26aa5a21326b6c1c7aaf35029222223f", + "rev": "887399d3d0a85d0e27a6688ae384459376adf7ca", "url_base": "/", "version": 2 } diff --git a/tests/wpt/metadata/dom/nodes/attributes.html.ini b/tests/wpt/metadata/dom/nodes/attributes.html.ini index f72ae139de1..db20558e450 100644 --- a/tests/wpt/metadata/dom/nodes/attributes.html.ini +++ b/tests/wpt/metadata/dom/nodes/attributes.html.ini @@ -12,3 +12,18 @@ [Basic functionality of setAttributeNodeNS] expected: FAIL + [getAttributeNames tests] + expected: FAIL + + [Own property correctness with basic attributes] + expected: FAIL + + [Own property correctness with non-namespaced attribute before same-name namespaced one] + expected: FAIL + + [Own property correctness with namespaced attribute before same-name non-namespaced one] + expected: FAIL + + [Own property correctness with two namespaced attributes with the same name-with-prefix] + expected: FAIL + diff --git a/tests/wpt/metadata/mozilla-sync b/tests/wpt/metadata/mozilla-sync index 43e44efe50d..16df08f323c 100644 --- a/tests/wpt/metadata/mozilla-sync +++ b/tests/wpt/metadata/mozilla-sync @@ -1 +1 @@ -9c4ca39ebe57502b74d75aa9d6953b017d884f54 \ No newline at end of file +a900196b3f56fac46f86d8a8157a61f14fdca364 \ No newline at end of file diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-origin.htm b/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-origin.htm index bad2ec4d6c4..acdbddbf201 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-origin.htm +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-origin.htm @@ -3,7 +3,6 @@ XMLHttpRequest: worker scripts, origin and referrer - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-simple.htm b/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-simple.htm index f0613c1a2d7..a77ef6feedd 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-simple.htm +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/open-url-worker-simple.htm @@ -3,7 +3,6 @@ XMLHttpRequest: relative URLs in worker scripts resolved by script URL - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-aborted.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-aborted.html index cf639487b2d..0af6d9cf699 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-aborted.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-aborted.html @@ -11,7 +11,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html index 9ce5444d777..70cba4980fd 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-abortedonmain.html @@ -7,7 +7,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overrides.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overrides.html index 6366e311222..61a32bb1af0 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overrides.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overrides.html @@ -7,7 +7,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html index e479a30eeac..d29cbbbff53 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-overridesexpires.html @@ -8,7 +8,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-simple.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-simple.html index e7cf089b1ac..982cf552945 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-simple.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-simple.html @@ -8,7 +8,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-synconmain.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-synconmain.html index ce2537cbc0b..79430a9d327 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-synconmain.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-synconmain.html @@ -5,7 +5,6 @@ XHR2 Timeout Property Tests - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-twice.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-twice.html index f29bf9824f5..1423fd5dbd4 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-twice.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-twice.html @@ -4,7 +4,6 @@ XHR2 Timeout Property Tests - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html index e5dab5a3947..c3a4581f756 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-aborted.html @@ -11,7 +11,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html index c5d37c10f62..bf77d859c7f 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overrides.html @@ -7,7 +7,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html index c1e601dd130..180db52eacc 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-overridesexpires.html @@ -8,7 +8,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html index 1113dfcda97..135691fbd9c 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-simple.html @@ -8,7 +8,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html index f9c2d3c3ff6..423dcc93cc4 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-synconworker.html @@ -8,7 +8,6 @@ - diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html index fdf3646b34a..7e7107d4b6f 100644 --- a/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html +++ b/tests/wpt/web-platform-tests/XMLHttpRequest/xmlhttprequest-timeout-worker-twice.html @@ -8,7 +8,6 @@ - diff --git a/tests/wpt/web-platform-tests/cors/resources/cors-makeheader.py b/tests/wpt/web-platform-tests/cors/resources/cors-makeheader.py index afd9e3642ee..408e12d3f5b 100644 --- a/tests/wpt/web-platform-tests/cors/resources/cors-makeheader.py +++ b/tests/wpt/web-platform-tests/cors/resources/cors-makeheader.py @@ -36,7 +36,7 @@ def main(request, response): #Log that the preflight actually happened if we have an ident if 'token' in request.GET: - request.server.stash.put(request.GET['token']) + request.server.stash.put(request.GET['token'], True) if 'location' in request.GET: if code is None: diff --git a/tests/wpt/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html b/tests/wpt/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html index d96805e077e..6c255981263 100644 --- a/tests/wpt/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html +++ b/tests/wpt/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/attached-callback-test.html @@ -2,6 +2,7 @@ Attached callback of a custom element should be called + diff --git a/tests/wpt/web-platform-tests/dom/nodes/attributes.html b/tests/wpt/web-platform-tests/dom/nodes/attributes.html index 4cdee1e1d63..06752a94d52 100644 --- a/tests/wpt/web-platform-tests/dom/nodes/attributes.html +++ b/tests/wpt/web-platform-tests/dom/nodes/attributes.html @@ -459,4 +459,104 @@ test(function() { var el2 = document.createElement("div"); assert_throws("INUSE_ATTRIBUTE_ERR", function(){el2.setAttributeNode(attrNode)}); }, "setAttributeNode on bound attribute should throw InUseAttributeError") + +test(function() { + var el = document.createElement("div"); + el.setAttribute("foo", "bar"); + assert_equals(el.getAttributeNames().length, 1); + assert_equals(el.getAttributeNames()[0], el.attributes[0].name); + assert_equals(el.getAttributeNames()[0], "foo"); + + el.removeAttribute("foo"); + assert_equals(el.getAttributeNames().length, 0); + + el.setAttribute("foo", "bar"); + el.setAttributeNS("", "FOO", "bar"); + el.setAttributeNS("dummy1", "foo", "bar"); + el.setAttributeNS("dummy2", "dummy:foo", "bar"); + assert_equals(el.getAttributeNames().length, 4); + assert_equals(el.getAttributeNames()[0], "foo"); + assert_equals(el.getAttributeNames()[1], "FOO"); + assert_equals(el.getAttributeNames()[2], "foo"); + assert_equals(el.getAttributeNames()[3], "dummy:foo"); + assert_equals(el.getAttributeNames()[0], el.attributes[0].name); + assert_equals(el.getAttributeNames()[1], el.attributes[1].name); + assert_equals(el.getAttributeNames()[2], el.attributes[2].name); + assert_equals(el.getAttributeNames()[3], el.attributes[3].name); + + el.removeAttributeNS("", "FOO"); + assert_equals(el.getAttributeNames().length, 3); + assert_equals(el.getAttributeNames()[0], "foo"); + assert_equals(el.getAttributeNames()[1], "foo"); + assert_equals(el.getAttributeNames()[2], "dummy:foo"); + assert_equals(el.getAttributeNames()[0], el.attributes[0].name); + assert_equals(el.getAttributeNames()[1], el.attributes[1].name); + assert_equals(el.getAttributeNames()[2], el.attributes[2].name); +}, "getAttributeNames tests"); + +function getEnumerableOwnProps1(obj) { + var arr = []; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + arr.push(prop); + } + } + return arr; +} + +function getEnumerableOwnProps2(obj) { + return Object.getOwnPropertyNames(obj).filter( + (name) => Object.getOwnPropertyDescriptor(obj, name).enumerable) +} + +test(function() { + var el = document.createElement("div"); + el.setAttribute("a", ""); + el.setAttribute("b", ""); + assert_array_equals(getEnumerableOwnProps1(el.attributes), + ["0", "1"]) + assert_array_equals(getEnumerableOwnProps2(el.attributes), + ["0", "1"]) + assert_array_equals(Object.getOwnPropertyNames(el.attributes), + ["0", "1", "a", "b"]) +}, "Own property correctness with basic attributes"); + +test(function() { + var el = document.createElement("div"); + el.setAttributeNS("", "a", ""); + el.setAttribute("b", ""); + el.setAttributeNS("foo", "a", ""); + assert_array_equals(getEnumerableOwnProps1(el.attributes), + ["0", "1", "2"]) + assert_array_equals(getEnumerableOwnProps2(el.attributes), + ["0", "1", "2"]) + assert_array_equals(Object.getOwnPropertyNames(el.attributes), + ["0", "1", "2", "a", "b"]) +}, "Own property correctness with non-namespaced attribute before same-name namespaced one"); + +test(function() { + var el = document.createElement("div"); + el.setAttributeNS("foo", "a", ""); + el.setAttribute("b", ""); + el.setAttributeNS("", "a", ""); + assert_array_equals(getEnumerableOwnProps1(el.attributes), + ["0", "1", "2"]) + assert_array_equals(getEnumerableOwnProps2(el.attributes), + ["0", "1", "2"]) + assert_array_equals(Object.getOwnPropertyNames(el.attributes), + ["0", "1", "2", "a", "b"]) +}, "Own property correctness with namespaced attribute before same-name non-namespaced one"); + +test(function() { + var el = document.createElement("div"); + el.setAttributeNS("foo", "a:b", ""); + el.setAttributeNS("foo", "c:d", ""); + el.setAttributeNS("bar", "a:b", ""); + assert_array_equals(getEnumerableOwnProps1(el.attributes), + ["0", "1", "2"]) + assert_array_equals(getEnumerableOwnProps2(el.attributes), + ["0", "1", "2"]) + assert_array_equals(Object.getOwnPropertyNames(el.attributes), + ["0", "1", "2", "a:b", "c:d"]) +}, "Own property correctness with two namespaced attributes with the same name-with-prefix"); diff --git a/tests/wpt/web-platform-tests/hr-time/basic.html b/tests/wpt/web-platform-tests/hr-time/basic.html index aabdc55a706..a10548fc94a 100644 --- a/tests/wpt/web-platform-tests/hr-time/basic.html +++ b/tests/wpt/web-platform-tests/hr-time/basic.html @@ -7,7 +7,6 @@ - -
-
- - - - - -

Description

diff --git a/tests/wpt/web-platform-tests/navigation-timing/test_performance_attributes_exist_in_object.html b/tests/wpt/web-platform-tests/navigation-timing/test_performance_attributes_exist_in_object.html index 60fcdb521ab..0464758c62b 100644 --- a/tests/wpt/web-platform-tests/navigation-timing/test_performance_attributes_exist_in_object.html +++ b/tests/wpt/web-platform-tests/navigation-timing/test_performance_attributes_exist_in_object.html @@ -8,7 +8,6 @@ - -

Description

diff --git a/tests/wpt/web-platform-tests/navigation-timing/test_timing_attributes_order.html b/tests/wpt/web-platform-tests/navigation-timing/test_timing_attributes_order.html index 5739eb92580..b607404b8b5 100644 --- a/tests/wpt/web-platform-tests/navigation-timing/test_timing_attributes_order.html +++ b/tests/wpt/web-platform-tests/navigation-timing/test_timing_attributes_order.html @@ -8,7 +8,6 @@ - - - -

Description

diff --git a/tests/wpt/web-platform-tests/resources/docs/api.md b/tests/wpt/web-platform-tests/resources/docs/api.md index accd18b8a42..1405cfdfecf 100644 --- a/tests/wpt/web-platform-tests/resources/docs/api.md +++ b/tests/wpt/web-platform-tests/resources/docs/api.md @@ -60,7 +60,7 @@ metadata, as described in the [metadata](#metadata) section below. Testing asynchronous features is somewhat more complex since the result of a test may depend on one or more events or other callbacks. The API provided -for testing these features is indended to be rather low-level but hopefully +for testing these features is intended to be rather low-level but hopefully applicable to many situations. To create a test, one starts by getting a Test object using async_test: @@ -225,7 +225,7 @@ wrapping everything in functions for isolation becomes burdensome. For these cases `testharness.js` support "single page tests". -In order for a test to be interpreted as a single page test, the +In order for a test to be interpreted as a single page test, then it must simply not call `test()` or `async_test()` anywhere on the page, and must call the `done()` function to indicate that the test is complete. All the `assert_*` functions are avaliable as normal, but are called without @@ -243,7 +243,7 @@ the normal step function wrapper. For example: ``` -The test title for sinple page tests is always taken from `document.title`. +The test title for single page tests is always taken from `document.title`. ## Making assertions ## @@ -424,8 +424,8 @@ The framework provides callbacks corresponding to 4 events: * `start` - triggered when the first Test is created * `test_state` - triggered when a test state changes - * `result` - triggered when a test result is recieved - * `complete` - triggered when all results are recieved + * `result` - triggered when a test result is received + * `complete` - triggered when all results are received The page defining the tests may add callbacks for these events by calling the following methods: diff --git a/tests/wpt/web-platform-tests/tools/manifest/item.py b/tests/wpt/web-platform-tests/tools/manifest/item.py index 3dee3173bd0..58ff22a3b0e 100644 --- a/tests/wpt/web-platform-tests/tools/manifest/item.py +++ b/tests/wpt/web-platform-tests/tools/manifest/item.py @@ -2,17 +2,11 @@ import os import urlparse from abc import ABCMeta, abstractmethod, abstractproperty +from utils import from_os_path, to_os_path + item_types = ["testharness", "reftest", "manual", "stub", "wdspec"] -def from_os_path(path): - return path.replace(os.path.sep, "/") - - -def to_os_path(path): - return path.replace("/", os.path.sep) - - def get_source_file(source_files, tests_root, manifest, path): def make_new(): from sourcefile import SourceFile diff --git a/tests/wpt/web-platform-tests/tools/manifest/manifest.py b/tests/wpt/web-platform-tests/tools/manifest/manifest.py index 75a7aef0298..1128f416ddb 100644 --- a/tests/wpt/web-platform-tests/tools/manifest/manifest.py +++ b/tests/wpt/web-platform-tests/tools/manifest/manifest.py @@ -5,6 +5,7 @@ from collections import defaultdict from item import item_types, ManualTest, WebdriverSpecTest, Stub, RefTest, TestharnessTest from log import get_logger from sourcefile import SourceFile +from utils import from_os_path, to_os_path CURRENT_VERSION = 2 @@ -207,7 +208,7 @@ class Manifest(object): for item_type, items in self._data.iteritems() } - reftest_nodes = {key:[v.to_json() for v in value] + reftest_nodes = {from_os_path(key): [v.to_json() for v in value] for key, value in self.reftest_nodes.iteritems()} rv = {"url_base": self.url_base, @@ -246,6 +247,7 @@ class Manifest(object): self._add(manifest_item) for path, values in obj["reftest_nodes"].iteritems(): + path = to_os_path(path) for v in values: item = RefTest.from_json(self, tests_root, v, source_files=source_files) @@ -306,17 +308,16 @@ class LocalChanges(object): return self._data[item_type] def to_json(self): - reftest_nodes = {key:[v.to_json() for v in value] + reftest_nodes = {from_os_path(key): [v.to_json() for v in value] for key, value in self.reftest_nodes.iteritems()} rv = {"items": defaultdict(dict), "reftest_nodes": reftest_nodes, - "deleted": []} - - rv["deleted"].extend(self._deleted) + "deleted": [from_os_path(path) for path in self._deleted]} for test_type, paths in self._data.iteritems(): for path, tests in paths.iteritems(): + path = from_os_path(path) rv["items"][test_type][path] = [test.to_json() for test in tests] return rv @@ -343,6 +344,7 @@ class LocalChanges(object): self.add(manifest_item) for path, values in obj["reftest_nodes"].iteritems(): + path = to_os_path(path) for v in values: item = RefTest.from_json(self.manifest, tests_root, v, source_files=source_files) @@ -350,7 +352,7 @@ class LocalChanges(object): self.reftest_nodes_by_url[item.url] = item for item in obj["deleted"]: - self.add_deleted(item) + self.add_deleted(to_os_path(item)) return self diff --git a/tests/wpt/web-platform-tests/tools/manifest/utils.py b/tests/wpt/web-platform-tests/tools/manifest/utils.py index 60e00ee74d3..668b14c05ba 100644 --- a/tests/wpt/web-platform-tests/tools/manifest/utils.py +++ b/tests/wpt/web-platform-tests/tools/manifest/utils.py @@ -21,6 +21,12 @@ def is_blacklisted(url): return True return False +def from_os_path(path): + return path.replace(os.path.sep, "/") + +def to_os_path(path): + return path.replace("/", os.path.sep) + class ContextManagerStringIO(StringIO): def __enter__(self): return self diff --git a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py index be95c7245e1..77060193140 100644 --- a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py +++ b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/handlers.py @@ -137,7 +137,9 @@ class FileHandler(object): if "pipe" in query: pipeline = Pipeline(query["pipe"][-1]) elif os.path.splitext(path)[0].endswith(".sub"): - pipeline = Pipeline("sub") + ml_extensions = {".html", ".htm", ".xht", ".xhtml", ".xml", ".svg"} + escape_type = "html" if os.path.splitext(path)[1] in ml_extensions else "none" + pipeline = Pipeline("sub(%s)" % escape_type) if pipeline is not None: response = pipeline(request, response) @@ -167,7 +169,7 @@ class FileHandler(object): return [] else: if use_sub: - data = template(request, data) + data = template(request, data, escape_type="none") return [tuple(item.strip() for item in line.split(":", 1)) for line in data.splitlines() if line] diff --git a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py index d629449f5d2..80d7944d26b 100644 --- a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py +++ b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/pipes.py @@ -313,10 +313,13 @@ class FirstWrapper(object): return "" -@pipe() -def sub(request, response): +@pipe(opt(nullable(str))) +def sub(request, response, escape_type="html"): """Substitute environment information about the server and request into the script. + :param escape_type: String detailing the type of escaping to use. Known values are + "html" and "none", with "html" the default for historic reasons. + The format is a very limited template language. Substitutions are enclosed by {{ and }}. There are several avaliable substitutions: @@ -359,12 +362,12 @@ def sub(request, response): """ content = resolve_content(response) - new_content = template(request, content) + new_content = template(request, content, escape_type=escape_type) response.content = new_content return response -def template(request, content): +def template(request, content, escape_type="html"): #TODO: There basically isn't any error handling here tokenizer = ReplacementTokenizer() @@ -419,9 +422,12 @@ def template(request, content): if variable is not None: variables[variable] = value + escape_func = {"html": lambda x:escape(x, quote=True), + "none": lambda x:x}[escape_type] + #Should possibly support escaping for other contexts e.g. script #TODO: read the encoding of the response - return escape(unicode(value), quote=True).encode("utf-8") + return escape_func(unicode(value)).encode("utf-8") template_regexp = re.compile(r"{{([^}]*)}}") new_content, count = template_regexp.subn(config_replacement, content) diff --git a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py index 410ddf06436..56476176e82 100644 --- a/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py +++ b/tests/wpt/web-platform-tests/tools/wptserve/wptserve/stash.py @@ -119,7 +119,7 @@ class Stash(object): if internal_key in self.data: raise StashError("Tried to overwrite existing shared stash value " "for key %s (old value was %s, new value is %s)" % - (internal_key, self[str(internal_key)], value)) + (internal_key, self.data[str(internal_key)], value)) else: self.data[internal_key] = value