blob: e628edaf6c93e3ffb5a6b959ba158d153c996d0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// 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 Polymer elements.
*/
/**
* Test fixture for Polymer element testing.
* @constructor
* @extends testing.Test
*/
function PolymerTest() {
}
PolymerTest.prototype = {
__proto__: testing.Test.prototype,
/**
* Navigate to a WebUI to satisfy BrowserTest conditions. Override to load a
* more useful WebUI.
* @override
*/
browsePreload: 'chrome://chrome-urls/',
/**
* The mocha adapter assumes all tests are async.
* @override
* @final
*/
isAsync: true,
/**
* @override
* @final
*/
extraLibraries: ['../../../../third_party/mocha/mocha.js',
'mocha_adapter.js'],
/** @override */
setUp: function() {
testing.Test.prototype.setUp.call(this);
// Import Polymer before running tests.
suiteSetup(function(done) {
var link = document.createElement('link');
link.rel = 'import';
link.onload = function() {
done();
};
link.onerror = function() {
done(new Error('Failed to load Polymer!'));
};
link.href = 'chrome://resources/polymer/v0_8/polymer/polymer.html';
document.head.appendChild(link);
});
},
};
/**
* Imports the HTML file, then calls |done| on success or throws an error.
* @param {String} href The URL to load.
* @param {Function} done The done callback.
*/
PolymerTest.importHref = function(href, done) {
Polymer.Base.importHref(
href,
function() { done(); },
function() { throw new Error('Failed to load ' + href); });
};
/**
* Removes all content from the body.
*/
PolymerTest.clearBody = function() {
document.body.innerHTML = '';
};
|