Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/common/vendor-prefix.js

Issue 2015623004: Import wpt@ed94c51f3dfaa5ff4c9c311add1a560408059c51 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /*
2 * Distributed under both the W3C Test Suite License [1] and the W3C
3 * 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
4 * policies and contribution forms [3].
5 *
6 * [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
7 * [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
8 * [3] http://www.w3.org/2004/10/27-testcases
9 * */
10
11 /* Source: https://github.com/w3c/web-platform-tests/blob/master/common/vendor-p refix.js
12 * The file has been modified to always be on (i.e. does not require usePrefixes =1 to
13 * start replacing prefixes). */
14
15 /* Use this script when you want to test APIs that use vendor prefixes 1 /* Use this script when you want to test APIs that use vendor prefixes
16 and define which objects need to be checked for prefixed versions, à la 2 and define which objects need to be checked for prefixed versions, à la
17 <script src="vendor-prefix.js" 3 <script src="vendor-prefix.js"
18 data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}] ' 4 data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}] '
19 data-prefixed-prototypes='[{"ancestors":["HTMLMediaElement"],"name":"srcObjec t"}]'></script> 5 data-prefixed-prototypes='[{"ancestors":["HTMLMediaElement"],"name":"srcObjec t"}]'></script>
20 data-prefixed-objects lets prefix objects in the global space 6 data-prefixed-objects lets prefix objects in the global space
21 data-prefixed-prototypes adds prefixes to interfaces, for objects that 7 data-prefixed-prototypes adds prefixes to interfaces, for objects that
22 get created during the tests 8 get created during the tests
23 9
24 NB: vendor prefixes are expected to go away in favor of putting 10 NB: vendor prefixes are expected to go away in favor of putting
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 vendorPrefixes.forEach(function (prefix) { 57 vendorPrefixes.forEach(function (prefix) {
72 if (parent[prependPrefix(prefix, obj.name)] !== undefined) { 58 if (parent[prependPrefix(prefix, obj.name)] !== undefined) {
73 parent[obj.name] = parent[prependPrefix(prefix, obj.name)]; 59 parent[obj.name] = parent[prependPrefix(prefix, obj.name)];
74 aliases[obj.ancestors.join(".") + "." + obj.name] = obj.ance stors.join(".") + "." + prependPrefix(prefix, obj.name); 60 aliases[obj.ancestors.join(".") + "." + obj.name] = obj.ance stors.join(".") + "." + prependPrefix(prefix, obj.name);
75 return; 61 return;
76 } 62 }
77 }); 63 });
78 } 64 }
79 } 65 }
80 66
81 // For this version of vendor-prefixes.js, always replace the prefixes. 67 if (location.search.indexOf('usePrefixes=1') !== -1) {
82 if (document.querySelector("script[data-prefixed-objects]")) { 68 if (document.querySelector("script[data-prefixed-objects]")) {
83 var prefixObjectsData = document.querySelector("script[data-prefixed-obj ects]").dataset["prefixedObjects"]; 69 var prefixObjectsData = document.querySelector("script[data-prefixed -objects]").dataset["prefixedObjects"];
84 try { 70 try {
85 var prefixedObjects = JSON.parse(prefixObjectsData); 71 var prefixedObjects = JSON.parse(prefixObjectsData);
86 } catch (e) { 72 } catch (e) {
87 throw "couldn't parse data-prefixed-objects as JSON:" + e; 73 throw "couldn't parse data-prefixed-objects as JSON:" + e;
74 }
75 prefixedObjects.forEach(setAlias);
88 } 76 }
89 prefixedObjects.forEach(setAlias); 77 if (document.querySelector("script[data-prefixed-prototypes]")) {
78 var prefixProtoData = document.querySelector("script[data-prefixed-p rototypes]").dataset["prefixedPrototypes"];
79 try {
80 var prefixedPrototypes = JSON.parse(prefixProtoData);
81 } catch (e) {
82 throw "couldn't parse data-prefixed-prototypes as JSON:" + e;
83 }
84 prefixedPrototypes.forEach(setPrototypeAlias);
85 }
86 var ul = document.createElement("ul");
87 Object.keys(aliases).forEach(function (alias) {
88 var li = document.createElement("li");
89 li.appendChild(document.createTextNode(alias + " has been set to be an alias of vendor-prefixed " + aliases[alias]));
90 ul.appendChild(li);
91 });
92 documentingPrefixUsage.appendChild(ul);
93 } else {
94 // Document that the test can be run with prefixes enabled
95
96 var a = document.createElement('a');
97 var link = "";
98 if (location.search) {
99 link = location.search + "&usePrefixes=1";
100 } else {
101 link = "?usePrefixes=1";
102 }
103 a.setAttribute("href", link);
104 a.appendChild(document.createTextNode("with vendor prefixes enabled"));
105 documentingPrefixUsage.appendChild(document.createTextNode("The feature( s) tested here are known to have been made available via vendor prefixes; you ca n run this test "));
106 documentingPrefixUsage.appendChild(a);
107 documentingPrefixUsage.appendChild(document.createTextNode("."));
90 } 108 }
91 if (document.querySelector("script[data-prefixed-prototypes]")) { 109 var log = document.getElementById('log');
92 var prefixProtoData = document.querySelector("script[data-prefixed-proto types]").dataset["prefixedPrototypes"]; 110 if (log) {
93 try { 111 log.parentNode.insertBefore(documentingPrefixUsage, log);
94 var prefixedPrototypes = JSON.parse(prefixProtoData); 112 } else {
95 } catch (e) { 113 document.body.appendChild(documentingPrefixUsage);
96 throw "couldn't parse data-prefixed-prototypes as JSON:" + e;
97 }
98 prefixedPrototypes.forEach(setPrototypeAlias);
99 } 114 }
100 })(); 115 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698