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

Side by Side Diff: test/js_test_tools/mocha-htmltest.js

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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 | « test/js_test_tools/htmltest.js ('k') | test/js_test_tools/mocha/.bower.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /**
2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
6 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
7 * Code distributed by Google as part of the polymer project is also
8 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
9 */
10
11 (function() {
12 var thisFile = 'lib/mocha-htmltest.js';
13 var base = '';
14
15 mocha.htmlbase = function(htmlbase) {
16 base = htmlbase;
17 };
18
19 (function() {
20 var s$ = document.querySelectorAll('script[src]');
21 Array.prototype.forEach.call(s$, function(s) {
22 var src = s.getAttribute('src');
23 var re = new RegExp(thisFile + '[^\\\\]*');
24 var match = src.match(re);
25 if (match) {
26 base = src.slice(0, -match[0].length);
27 }
28 });
29 })();
30
31 var next, iframe;
32
33 var listener = function(event) {
34 if (event.data === 'ok') {
35 next();
36 } else if (event.data && event.data.error) {
37 // errors cannot be cloned via postMessage according to spec, so we re-err orify them
38 throw new Error(event.data.error);
39 }
40 };
41
42 function htmlSetup() {
43 window.addEventListener("message", listener);
44 iframe = document.createElement('iframe');
45 iframe.style.cssText = 'position: absolute; left: -9000em; width:768px; heig ht: 1024px';
46 document.body.appendChild(iframe);
47 }
48
49 function htmlTeardown() {
50 window.removeEventListener('message', listener);
51 document.body.removeChild(iframe);
52 }
53
54 function htmlTest(src) {
55 var basePath = calcBase();
56 test(src, function(done) {
57 next = done;
58 var url = basePath + src;
59 var delimiter = url.indexOf('?') < 0 ? '?' : '&';
60 var docSearch = location.search.slice(1);
61 iframe.src = url + delimiter + Math.random() + '&' + docSearch;
62 });
63 };
64
65 function htmlSuite(inName, inFn) {
66 suite(inName, function() {
67 setup(htmlSetup);
68 teardown(htmlTeardown);
69 inFn();
70 });
71 };
72
73 function calcBase() {
74 var b = base;
75 var script = document._currentScript ||
76 document.scripts[document.scripts.length - 1];
77 if (script) {
78 var parts = script.src.split('/');
79 parts.pop();
80 b = parts.join('/') + '/';
81 }
82 return b;
83 }
84
85 window.htmlTest = htmlTest;
86 window.htmlSuite = htmlSuite;
87 })();
OLDNEW
« no previous file with comments | « test/js_test_tools/htmltest.js ('k') | test/js_test_tools/mocha/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698