Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions tests/generators/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* If some tests are failing, load test suites individually to continue
* debugging.
*/
function loadSelected() {
async function loadSelected() {
var output = document.getElementById('importExport');
output.style.background = 'gray';

Expand All @@ -53,9 +53,12 @@
if (boxList[i].checked) {
var testUrl = boxList[i].value;
if (testUrl) {
var xmlText = fetchFile(testUrl);
var xmlText = await fetchFile(testUrl);
if (xmlText !== null) {
fromXml(testUrl, xmlText, /* opt_append */ true);
// Clean up the workspace to normalize the position of blocks and
// thus the order of functions in the generated code.
Blockly.getMainWorkspace().cleanUp();
}
}
}
Expand All @@ -67,23 +70,24 @@
/**
* Ask the user for a file name, then load that file's contents.
*/
function loadOther() {
async function loadOther() {
var url = window.prompt('Enter URL of test file.');
if (!url) {
return;
}
var xmlText = fetchFile(url);
var xmlText = await fetchFile(url);
if (xmlText !== null) {
fromXml(url, xmlText);
}
}

function fetchFile(xmlUrl) {
async function fetchFile(xmlUrl) {
try {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', xmlUrl, false);
xmlHttp.setRequestHeader('Content-Type', 'text/xml');
xmlHttp.send('');
const response = await fetch(xmlUrl);
if (!response.ok) {
throw new Error(`Got a 404 when loading ${xmlUrl}`);
}
return response.text();
} catch (e) {
// Attempt to diagnose the problem.
var msg = 'Error: Unable to load XML data.\n';
Expand All @@ -95,7 +99,6 @@
alert(msg + '\n' + e);
return null;
}
return xmlHttp.responseText;
}

/**
Expand Down Expand Up @@ -188,7 +191,7 @@
function changeIndex() {
var oneBasedIndex = document.getElementById('indexing').checked;
demoWorkspace.options.oneBasedIndex = oneBasedIndex;
demoWorkspace.getToolbox().flyout_.workspace_.options.oneBasedIndex = oneBasedIndex;
demoWorkspace.getToolbox().getFlyout().getWorkspace().options.oneBasedIndex = oneBasedIndex;
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion tests/generators/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function runGeneratorsInBrowser(outputDir) {

await browser.execute(function() {
checkAll();
loadSelected();
return loadSelected();
});

await runLangGeneratorInBrowser(browser, prefix + '.js',
Expand Down
Loading