| Index: chrome/test/data/webui/web_component_test.js
|
| diff --git a/chrome/test/data/webui/web_component_test.js b/chrome/test/data/webui/web_component_test.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6b5584953c6c2537f967345265551e99176321b5
|
| --- /dev/null
|
| +++ b/chrome/test/data/webui/web_component_test.js
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * @fileoverview Framework for running JavaScript tests of web components.
|
| + */
|
| +
|
| +// Namespace for web component tests.
|
| +var wcTest = (function() {
|
| + /**
|
| + * @constructor
|
| + * @extends testing.Test
|
| + */
|
| + function BrowserTest() {}
|
| +
|
| + BrowserTest.prototype = {
|
| + __proto__: testing.Test.prototype,
|
| +
|
| + /**
|
| + * @override
|
| + * Navigate to the test WebUI.
|
| + */
|
| + browsePreload: 'chrome://web-component-test/',
|
| +
|
| + /**
|
| + * The Mocha adapter assumes all tests are async.
|
| + * @override
|
| + * @final
|
| + */
|
| + isAsync: true,
|
| + };
|
| +
|
| + /**
|
| + * Chains asynchronous functions to avoid nested setTimeouts.
|
| + * @return {Promise} A promise resolved after a minimal timeout.
|
| + */
|
| + function async() {
|
| + return new Promise(function(resolve, reject) {
|
| + setTimeout(resolve);
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Removes all content from the body.
|
| + */
|
| + function clear() {
|
| + document.body.innerHTML = '';
|
| + }
|
| +
|
| + /**
|
| + * Imports HTML using a <link> element.
|
| + * @param {string} uri The URI of the source to import.
|
| + * @return {Promise} A promise fulfilled when the link loads or errors out.
|
| + */
|
| + function importHtml(uri) {
|
| + var link = document.createElement('link');
|
| + link.rel = 'import';
|
| + link.href = uri;
|
| + document.head.appendChild(link);
|
| + return new Promise(function(resolve, reject) {
|
| + link.onload = function() {
|
| + resolve();
|
| + };
|
| + link.onerror = function() {
|
| + reject(new Error('Failed to import: ' + uri));
|
| + };
|
| + });
|
| + }
|
| +
|
| + return {
|
| + BrowserTest: BrowserTest,
|
| + async: async,
|
| + clear: clear,
|
| + importHtml: importHtml,
|
| + };
|
| +})();
|
|
|