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

Side by Side Diff: tests/html/utils.dart

Issue 2980303002: Revert "Remove several packages from DEPS" (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « DEPS ('k') | tests/lib_strong/html/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library TestUtils; 1 library TestUtils;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:html'; 4 import 'dart:html';
5 import 'dart:js' as js; 5 import 'dart:js' as js;
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 export 'package:web_components/polyfill.dart';
8 9
9 /** 10 /**
10 * Verifies that [actual] has the same graph structure as [expected]. 11 * Verifies that [actual] has the same graph structure as [expected].
11 * Detects cycles and DAG structure in Maps and Lists. 12 * Detects cycles and DAG structure in Maps and Lists.
12 */ 13 */
13 verifyGraph(expected, actual) { 14 verifyGraph(expected, actual) {
14 var eItems = []; 15 var eItems = [];
15 var aItems = []; 16 var aItems = [];
16 17
17 message(path, reason) => path == '' 18 message(path, reason) => path == ''
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 * 160 *
160 * This is needed to cover timing scenarios which the custom element polyfill 161 * This is needed to cover timing scenarios which the custom element polyfill
161 * does not cover. 162 * does not cover.
162 */ 163 */
163 void upgradeCustomElements(Node node) { 164 void upgradeCustomElements(Node node) {
164 if (js.context.hasProperty('CustomElements') && 165 if (js.context.hasProperty('CustomElements') &&
165 js.context['CustomElements'].hasProperty('upgradeAll')) { 166 js.context['CustomElements'].hasProperty('upgradeAll')) {
166 js.context['CustomElements'].callMethod('upgradeAll', [node]); 167 js.context['CustomElements'].callMethod('upgradeAll', [node]);
167 } 168 }
168 } 169 }
169
170 /**
171 * A future that completes once all custom elements in the initial HTML page
172 * have been upgraded.
173 *
174 * This is needed because the native implementation can update the elements
175 * while parsing the HTML document, but the custom element polyfill cannot,
176 * so it completes this future once all elements are upgraded.
177 */
178 // TODO(jmesserly): rename to webComponentsReady to match the event?
179 Future customElementsReady = () {
180 if (_isReady) return new Future.value();
181
182 // Not upgraded. Wait for the polyfill to fire the WebComponentsReady event.
183 // Note: we listen on document (not on document.body) to allow this polyfill
184 // to be loaded in the HEAD element.
185 return document.on['WebComponentsReady'].first;
186 }();
187
188 // Return true if we are using the polyfill and upgrade is complete, or if we
189 // have native document.register and therefore the browser took care of it.
190 // Otherwise return false, including the case where we can't find the polyfill.
191 bool get _isReady {
192 // If we don't have dart:js, assume things are ready
193 if (js.context == null) return true;
194
195 var customElements = js.context['CustomElements'];
196 if (customElements == null) {
197 // Return true if native document.register, otherwise false.
198 // (Maybe the polyfill isn't loaded yet. Wait for it.)
199 return document.supportsRegisterElement;
200 }
201
202 return customElements['ready'] == true;
203 }
204
205 /**
206 * *Note* this API is primarily intended for tests. In other code it is better
207 * to write it in a style that works with or without the polyfill, rather than
208 * using this method.
209 *
210 * Synchronously trigger evaluation of pending lifecycle events, which otherwise
211 * need to wait for a [MutationObserver] to signal the changes in the polyfill.
212 * This method can be used to resolve differences in timing between native and
213 * polyfilled custom elements.
214 */
215 void customElementsTakeRecords([Node node]) {
216 var customElements = js.context['CustomElements'];
217 if (customElements == null) return;
218 customElements.callMethod('takeRecords', [node]);
219 }
OLDNEW
« no previous file with comments | « DEPS ('k') | tests/lib_strong/html/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698