Skip to content

Commit

Permalink
Merge pull request #8466 from AnalyticalGraphicsInc/chrome-79-bug
Browse files Browse the repository at this point in the history
Workaround Chrome 79 bug.
  • Loading branch information
mramato authored Dec 14, 2019
2 parents 2c488cc + 05b03be commit 59110b8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Apps/Sandcastle/CesiumSandcastle.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ require({
'dojo/promise/all',
'dojo/query',
'dojo/when',
'dojo/Deferred',
'dojo/request/script',
'Sandcastle/LinkButton',
'ThirdParty/clipboard.min',
Expand Down Expand Up @@ -87,6 +88,7 @@ require({
all,
query,
when,
Deferred,
dojoscript,
LinkButton,
ClipboardJS,
Expand Down Expand Up @@ -739,6 +741,10 @@ require({
var parser = new DOMParser();
var doc = parser.parseFromString(demo.code, 'text/html');

return waitForDoc(doc, function(){
return doc.querySelector('script[id="cesium_sandcastle_script"]');
}).then(function(){

var script = doc.querySelector('script[id="cesium_sandcastle_script"]');
if (!script) {
appendConsole('consoleError', 'Error reading source file: ' + demo.name, true);
Expand All @@ -763,6 +769,7 @@ require({
htmlText = htmlText.replace(/^\s+/, '');

applyLoadedDemo(scriptCode, htmlText);
});
}
});
}
Expand Down Expand Up @@ -1050,6 +1057,22 @@ require({
});
}

// Work around Chrome 79 bug: https://github.com/AnalyticalGraphicsInc/cesium/issues/8460
function waitForDoc(doc, test) {
var deferred = new Deferred();
if (test()) {
deferred.resolve(doc);
} else {
var counter = 1;
setTimeout(function() {
if (test() || counter++ > 10) {
deferred.resolve(doc);
}
}, 100 * counter);
}
return deferred.promise;
}

var newInLabel = 'New in ' + VERSION;
function loadDemoFromFile(demo) {
return requestDemo(demo.name).then(function(value) {
Expand All @@ -1058,6 +1081,10 @@ require({

var parser = new DOMParser();
var doc = parser.parseFromString(value, 'text/html');
return waitForDoc(doc, function(){
return doc.body.getAttribute('data-sandcastle-bucket');
});
}).then(function(doc) {

var bucket = doc.body.getAttribute('data-sandcastle-bucket');
demo.bucket = bucket ? bucket : 'bucket-requirejs.html';
Expand Down

0 comments on commit 59110b8

Please sign in to comment.