mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
don't run example tests on older safari
This commit is contained in:
parent
9fe0d1546a
commit
919de12cfa
2 changed files with 59 additions and 54 deletions
|
@ -1,61 +1,65 @@
|
|||
define(["Test", "Examples"], function (Test, Examples) {
|
||||
define(["Test", "Examples", "helper/Supports"], function (Test, Examples, Supports) {
|
||||
|
||||
var baseUrl = "../examples/";
|
||||
if (window.__karma__){
|
||||
baseUrl = "/base/examples/";
|
||||
}
|
||||
|
||||
function getIframeError(url){
|
||||
return new Promise(function(success, error){
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.onload = function(){
|
||||
iframe.remove();
|
||||
success();
|
||||
};
|
||||
iframe.width = 1;
|
||||
iframe.height = 1;
|
||||
iframe.src = url;
|
||||
document.body.appendChild(iframe);
|
||||
//capture the error
|
||||
iframe.contentWindow.onerror=function(e) {
|
||||
error(e);
|
||||
};
|
||||
});
|
||||
}
|
||||
if (Supports.RUN_EXAMPLES){
|
||||
|
||||
function createTest(url){
|
||||
|
||||
it (url, function(){
|
||||
url = baseUrl + url + ".html";
|
||||
return testUrl(url).then(getIframeError);
|
||||
});
|
||||
}
|
||||
|
||||
function testUrl(url){
|
||||
return new Promise(function(success, fail){
|
||||
var httpRequest = new XMLHttpRequest();
|
||||
httpRequest.onreadystatechange = function() {
|
||||
if (httpRequest.readyState === 4) {
|
||||
if (httpRequest.status === 200) {
|
||||
success(url);
|
||||
} else {
|
||||
fail("404: "+url);
|
||||
}
|
||||
}
|
||||
};
|
||||
httpRequest.open("GET", url);
|
||||
httpRequest.send();
|
||||
});
|
||||
}
|
||||
|
||||
context("Examples", function(){
|
||||
|
||||
for (var category in Examples){
|
||||
var group = Examples[category];
|
||||
for (var name in group){
|
||||
var url = group[name];
|
||||
createTest(url);
|
||||
}
|
||||
function getIframeError(url){
|
||||
return new Promise(function(success, error){
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.onload = function(){
|
||||
iframe.remove();
|
||||
success();
|
||||
};
|
||||
iframe.width = 1;
|
||||
iframe.height = 1;
|
||||
iframe.src = url;
|
||||
document.body.appendChild(iframe);
|
||||
//capture the error
|
||||
iframe.contentWindow.onerror=function(e) {
|
||||
error(e);
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function createTest(url){
|
||||
|
||||
it (url, function(){
|
||||
url = baseUrl + url + ".html";
|
||||
return testUrl(url).then(getIframeError);
|
||||
});
|
||||
}
|
||||
|
||||
function testUrl(url){
|
||||
return new Promise(function(success, fail){
|
||||
var httpRequest = new XMLHttpRequest();
|
||||
httpRequest.onreadystatechange = function() {
|
||||
if (httpRequest.readyState === 4) {
|
||||
if (httpRequest.status === 200) {
|
||||
success(url);
|
||||
} else {
|
||||
fail("404: "+url);
|
||||
}
|
||||
}
|
||||
};
|
||||
httpRequest.open("GET", url);
|
||||
httpRequest.send();
|
||||
});
|
||||
}
|
||||
|
||||
context("Examples", function(){
|
||||
|
||||
for (var category in Examples){
|
||||
var group = Examples[category];
|
||||
for (var name in group){
|
||||
var url = group[name];
|
||||
createTest(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -38,6 +38,7 @@ define(["helper/ua-parser"], function (UserAgentParser) {
|
|||
//the close method resolves a promise
|
||||
AUDIO_CONTEXT_CLOSE_RESOLVES : isnt("Firefox"),
|
||||
//if it supports gUM testing
|
||||
GET_USER_MEDIA : isnt("Safari")
|
||||
GET_USER_MEDIA : isnt("Safari"),
|
||||
RUN_EXAMPLES : isnt("Safari", 10)
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue