Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTim Buschtöns2011-01-19 11:16:45 +0000
committerTim Buschtöns2011-01-19 11:16:45 +0000
commit17a481a99f2ed39b29dffd81d135747738c813d9 (patch)
tree30acaa68019aba9f70c2064085cbe743355fb59c /tests
parent2a128c2cb283b6fe7754d6fe944c4ac85d4d0a4b (diff)
downloadorg.eclipse.rap-17a481a99f2ed39b29dffd81d135747738c813d9.tar.gz
org.eclipse.rap-17a481a99f2ed39b29dffd81d135747738c813d9.tar.xz
org.eclipse.rap-17a481a99f2ed39b29dffd81d135747738c813d9.zip
Fix for Bug 330361 - [Browser] cross-domain-scripting is not handled
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/TestRunner.js1
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js20
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js74
-rw-r--r--tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js9
-rw-r--r--tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/TestRunner.js1
-rw-r--r--tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js20
-rw-r--r--tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js74
-rw-r--r--tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js9
8 files changed, 182 insertions, 26 deletions
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/TestRunner.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/TestRunner.js
index 4cc1aff47f..613522676d 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/TestRunner.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/TestRunner.js
@@ -120,6 +120,7 @@ qx.Class.define("org.eclipse.rwt.test.TestRunner", {
this._disableAutoFlush();
// prevent actual dom-events
org.eclipse.rwt.EventHandler.detachEvents();
+ org.eclipse.rwt.test.fixture.TestUtil.initErrorPageLog();
var that = this;
this._loopWrapper = function(){ that._loop(); };
this.info( "Found " + this._testClasses.length + " Tests.", false );
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js
index e1bb8cd489..235d489283 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js
@@ -628,6 +628,7 @@ qx.Class.define( "org.eclipse.rwt.test.fixture.TestUtil", {
_requestLog : [],
_response : null,
+ _errorPage : null,
initRequestLog : function() {
var server = org.eclipse.rwt.test.fixture.RAPServer.getInstance();
@@ -659,10 +660,27 @@ qx.Class.define( "org.eclipse.rwt.test.fixture.TestUtil", {
getMessage : function(){
return this.getRequestLog()[ 0 ];
},
-
+
scheduleResponse : function( func ) {
this._response = func;
},
+
+ initErrorPageLog : function() {
+ var req = org.eclipse.swt.Request.getInstance();
+ org.eclipse.rwt.test.fixture.TestUtil.clearErrorPage();
+ req._writeErrorPage = function( content ) {
+ testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ testUtil._errorPage = content;
+ };
+ },
+
+ clearErrorPage : function() {
+ this._errorPage = null;
+ },
+
+ getErrorPage : function() {
+ return this._errorPage;
+ },
////////
// Timer
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js
index 9933857080..a05cd08620 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js
@@ -15,10 +15,30 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
BLANK : "../org.eclipse.rap.rwt.q07/resources/resource/static/html/blank.html",
+ testGetDomain : function() {
+ var url1 = "http://google.de/";
+ var url2 = "http://www.sub.somedomain.com:84/"
+ + "example/document.html?param=value&param2=%20value2"
+ var domain1 = org.eclipse.swt.browser.Browser.getDomain( url1 );
+ var domain2 = org.eclipse.swt.browser.Browser.getDomain( url2 );
+ assertEquals( "google.de", domain1 );
+ assertEquals( "www.sub.somedomain.com:84", domain2 );
+ },
+
+ testGetDomainFails : function() {
+ var url1 = "htp://google.de/";
+ var url2 = "http://www.sub.somedomain.com:84";
+ var domain1 = org.eclipse.swt.browser.Browser.getDomain( url1 );
+ var domain2 = org.eclipse.swt.browser.Browser.getDomain( url2 );
+ var domain3 = org.eclipse.swt.browser.Browser.getDomain( null );
+ assertNull( domain1 );
+ assertNull( domain2 );
+ assertNull( domain3 );
+ },
+
testExecute : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -46,7 +66,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluate : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -66,7 +85,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testExecuteFailed : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -86,7 +104,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsRegexp : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -106,7 +123,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsMap : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -126,7 +142,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsArray : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -146,7 +161,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsFunction : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -162,11 +176,50 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
browser.destroy();
}
],
-
+
+ testExecuteSecurityException : [
+ function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var browser = this._createBrowser();
+ browser.setSource( "http://www.google.de/" );
+ testUtil.delayTest( 1000 );
+ testUtil.store( browser );
+ },
+ function( browser ) {
+ var error = null;
+ try {
+ browser.execute( "alert(\" This should not happen\" );" );
+ } catch( ex ) {
+ error = ex;
+ }
+ assertTrue( error !== null );
+ }
+ ],
+
+ testBrowserFunctionSecurityExceptionInResponse : [
+ function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var browser = this._createBrowser();
+ browser.setSource( "http://www.google.de/" );
+ testUtil.delayTest( 1000 );
+ testUtil.store( browser );
+ },
+ function( browser ) {
+ org.eclipse.swt.EventUtil.setSuspended( true );
+ var error = null;
+ try {
+ browser.createFunction( "abc" );
+ } catch( ex ) {
+ error = ex;
+ }
+ org.eclipse.swt.EventUtil.setSuspended( false );
+ assertTrue( error !== null );
+ }
+ ],
+
testCreateDestroyBrowserFunction : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -189,7 +242,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testBrowserFunctionFailed : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -218,7 +270,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testBrowserFunctionSucceed : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -249,7 +300,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
function() {
// See Bug 327440 - Memory leak problem with Iframe in Internet Explorer
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
assertTrue( browser.isSeeable() );
assertFalse( browser.isLoaded() );
diff --git a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js
index 44fe5a9de2..f051e2e80d 100644
--- a/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js
+++ b/tests/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js
@@ -601,6 +601,15 @@ qx.Class.define( "org.eclipse.rwt.test.tests.TestUtilTest", {
assertEquals( 1, x );
},
+ testCatchErrorPage : function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ testUtil.clearErrorPage();
+ org.eclipse.swt.Request.getInstance()._writeErrorPage( "foobar" );
+ assertEquals( "foobar", testUtil.getErrorPage() );
+ testUtil.clearErrorPage();
+ assertNull( testUtil.getErrorPage() );
+ },
+
/////////
// helper
diff --git a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/TestRunner.js b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/TestRunner.js
index 4cc1aff47f..613522676d 100644
--- a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/TestRunner.js
+++ b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/TestRunner.js
@@ -120,6 +120,7 @@ qx.Class.define("org.eclipse.rwt.test.TestRunner", {
this._disableAutoFlush();
// prevent actual dom-events
org.eclipse.rwt.EventHandler.detachEvents();
+ org.eclipse.rwt.test.fixture.TestUtil.initErrorPageLog();
var that = this;
this._loopWrapper = function(){ that._loop(); };
this.info( "Found " + this._testClasses.length + " Tests.", false );
diff --git a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js
index e1bb8cd489..235d489283 100644
--- a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js
+++ b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/fixture/TestUtil.js
@@ -628,6 +628,7 @@ qx.Class.define( "org.eclipse.rwt.test.fixture.TestUtil", {
_requestLog : [],
_response : null,
+ _errorPage : null,
initRequestLog : function() {
var server = org.eclipse.rwt.test.fixture.RAPServer.getInstance();
@@ -659,10 +660,27 @@ qx.Class.define( "org.eclipse.rwt.test.fixture.TestUtil", {
getMessage : function(){
return this.getRequestLog()[ 0 ];
},
-
+
scheduleResponse : function( func ) {
this._response = func;
},
+
+ initErrorPageLog : function() {
+ var req = org.eclipse.swt.Request.getInstance();
+ org.eclipse.rwt.test.fixture.TestUtil.clearErrorPage();
+ req._writeErrorPage = function( content ) {
+ testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ testUtil._errorPage = content;
+ };
+ },
+
+ clearErrorPage : function() {
+ this._errorPage = null;
+ },
+
+ getErrorPage : function() {
+ return this._errorPage;
+ },
////////
// Timer
diff --git a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js
index 9933857080..a05cd08620 100644
--- a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js
+++ b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/BrowserTest.js
@@ -15,10 +15,30 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
BLANK : "../org.eclipse.rap.rwt.q07/resources/resource/static/html/blank.html",
+ testGetDomain : function() {
+ var url1 = "http://google.de/";
+ var url2 = "http://www.sub.somedomain.com:84/"
+ + "example/document.html?param=value&param2=%20value2"
+ var domain1 = org.eclipse.swt.browser.Browser.getDomain( url1 );
+ var domain2 = org.eclipse.swt.browser.Browser.getDomain( url2 );
+ assertEquals( "google.de", domain1 );
+ assertEquals( "www.sub.somedomain.com:84", domain2 );
+ },
+
+ testGetDomainFails : function() {
+ var url1 = "htp://google.de/";
+ var url2 = "http://www.sub.somedomain.com:84";
+ var domain1 = org.eclipse.swt.browser.Browser.getDomain( url1 );
+ var domain2 = org.eclipse.swt.browser.Browser.getDomain( url2 );
+ var domain3 = org.eclipse.swt.browser.Browser.getDomain( null );
+ assertNull( domain1 );
+ assertNull( domain2 );
+ assertNull( domain3 );
+ },
+
testExecute : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -46,7 +66,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluate : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -66,7 +85,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testExecuteFailed : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -86,7 +104,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsRegexp : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -106,7 +123,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsMap : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -126,7 +142,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsArray : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -146,7 +161,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testEvaluateReturnsFunction : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -162,11 +176,50 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
browser.destroy();
}
],
-
+
+ testExecuteSecurityException : [
+ function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var browser = this._createBrowser();
+ browser.setSource( "http://www.google.de/" );
+ testUtil.delayTest( 1000 );
+ testUtil.store( browser );
+ },
+ function( browser ) {
+ var error = null;
+ try {
+ browser.execute( "alert(\" This should not happen\" );" );
+ } catch( ex ) {
+ error = ex;
+ }
+ assertTrue( error !== null );
+ }
+ ],
+
+ testBrowserFunctionSecurityExceptionInResponse : [
+ function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ var browser = this._createBrowser();
+ browser.setSource( "http://www.google.de/" );
+ testUtil.delayTest( 1000 );
+ testUtil.store( browser );
+ },
+ function( browser ) {
+ org.eclipse.swt.EventUtil.setSuspended( true );
+ var error = null;
+ try {
+ browser.createFunction( "abc" );
+ } catch( ex ) {
+ error = ex;
+ }
+ org.eclipse.swt.EventUtil.setSuspended( false );
+ assertTrue( error !== null );
+ }
+ ],
+
testCreateDestroyBrowserFunction : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -189,7 +242,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testBrowserFunctionFailed : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -218,7 +270,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
testBrowserFunctionSucceed : [
function() {
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
testUtil.delayTest( 100 );
testUtil.store( browser );
@@ -249,7 +300,6 @@ qx.Class.define( "org.eclipse.rwt.test.tests.BrowserTest", {
function() {
// See Bug 327440 - Memory leak problem with Iframe in Internet Explorer
var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var browser = this._createBrowser();
assertTrue( browser.isSeeable() );
assertFalse( browser.isLoaded() );
diff --git a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js
index 44fe5a9de2..f051e2e80d 100644
--- a/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js
+++ b/tests/org.eclipse.rap.rwt.q07.jstest/js/org/eclipse/rwt/test/tests/TestUtilTest.js
@@ -601,6 +601,15 @@ qx.Class.define( "org.eclipse.rwt.test.tests.TestUtilTest", {
assertEquals( 1, x );
},
+ testCatchErrorPage : function() {
+ var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
+ testUtil.clearErrorPage();
+ org.eclipse.swt.Request.getInstance()._writeErrorPage( "foobar" );
+ assertEquals( "foobar", testUtil.getErrorPage() );
+ testUtil.clearErrorPage();
+ assertNull( testUtil.getErrorPage() );
+ },
+
/////////
// helper

Back to the top