]> source.dussan.org Git - vaadin-framework.git/commitdiff
Set bootstrap error using innerHTML instead of document.write (#9735) 54/354/1
authorLeif Åstrand <leif@vaadin.com>
Fri, 23 Nov 2012 09:21:31 +0000 (11:21 +0200)
committerLeif Åstrand <leif@vaadin.com>
Fri, 23 Nov 2012 09:21:31 +0000 (11:21 +0200)
* Also remove the testbench hook so waitForVaadin can continue
* Add automatic test

Change-Id: I6a6e53f23af9746f33977dfdb3768870956943f2

WebContent/VAADIN/vaadinBootstrap.js
uitest/src/com/vaadin/tests/components/ui/UIInitException.html [new file with mode: 0644]

index 8c6e80a14f4beafd63f2edec399782ce97109154..c4617df25c31f8af6b26bc0b564c643b76ef6253 100644 (file)
                                r.open('POST', url, true);
                                r.onreadystatechange = function (aEvt) {  
                                        if (r.readyState == 4) {
+                                               var text = r.responseText;
                                                if (r.status == 200){
-                                                       log("Got root config response", r.responseText);
-                                                       var updatedConfig = JSON.parse(r.responseText);
+                                                       log("Got root config response", text);
+                                                       var updatedConfig = JSON.parse(text);
                                                        
                                                        // Copy new properties to the config object
                                                        for (var property in updatedConfig) {
                                                        
                                                        // Try bootstrapping again, this time without fetching missing info
                                                        bootstrapApp(false);
-                                               } else if (r.status == 500) {
-                                                       document.write(r.responseText);
                                                } else {
-                                                       log('Error', r.statusText);  
+                                                       log('Error', r.statusText, text);
+                                                       
+                                                       //Let TB waitForVaadin work again
+                                                       delete window.vaadin.clients[testbenchId];
+                                                       
+                                                       // Show the error in the app's div
+                                                       var appDiv = document.getElementById(appId);
+                                                       appDiv.innerHTML = text;
+                                                       appDiv.style['overflow'] = 'auto';
                                                }
                                        }  
                                };
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIInitException.html b/uitest/src/com/vaadin/tests/components/ui/UIInitException.html
new file mode 100644 (file)
index 0000000..c2b1b33
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.ui.UIInitException?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>//html/body/div/pre</td>
+       <td>Catch me if you can</td>
+</tr>
+</tbody></table>
+</body>
+</html>