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

Side by Side Diff: bower_components/polymer-test-tools/mocha-htmltest.js

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 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
(Empty)
1 /*
2 * Copyright 2013 The Polymer Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
5 */
6
7 (function() {
8 var thisFile = 'lib/mocha-htmltest.js';
9 var base = '';
10
11 mocha.htmlbase = function(htmlbase) {
12 base = htmlbase;
13 };
14
15 (function() {
16 var s$ = document.querySelectorAll('script[src]');
17 Array.prototype.forEach.call(s$, function(s) {
18 var src = s.getAttribute('src');
19 var re = new RegExp(thisFile + '[^\\\\]*');
20 var match = src.match(re);
21 if (match) {
22 base = src.slice(0, -match[0].length);
23 }
24 });
25 })();
26
27 var next, iframe;
28
29 var listener = function(event) {
30 if (event.data === 'ok') {
31 next();
32 } else if (event.data && event.data.error) {
33 // errors cannot be cloned via postMessage according to spec, so we re-err orify them
34 throw new Error(event.data.error);
35 }
36 };
37
38 function htmlSetup() {
39 window.addEventListener("message", listener);
40 iframe = document.createElement('iframe');
41 iframe.style.cssText = 'position: absolute; left: -9000em; width:768px; heig ht: 1024px';
42 document.body.appendChild(iframe);
43 }
44
45 function htmlTeardown() {
46 window.removeEventListener('message', listener);
47 document.body.removeChild(iframe);
48 }
49
50 function htmlTest(src) {
51 test(src, function(done) {
52 next = done;
53 var url = base + src;
54 var delimiter = url.indexOf('?') < 0 ? '?' : '&';
55 var docSearch = location.search.slice(1);
56 iframe.src = url + delimiter + Math.random() + '&' + docSearch;
57 });
58 };
59
60 function htmlSuite(inName, inFn) {
61 suite(inName, function() {
62 setup(htmlSetup);
63 teardown(htmlTeardown);
64 inFn();
65 });
66 };
67
68 window.htmlTest = htmlTest;
69 window.htmlSuite = htmlSuite;
70 })();
OLDNEW
« no previous file with comments | « bower_components/polymer-test-tools/karma-common.conf.js ('k') | bower_components/polymer-test-tools/mocha/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698