
committed by
Kara Erickson

parent
7b3bcc23af
commit
5eb7426216
9
packages/zone.js/test/webdriver/test-es2015.html
Normal file
9
packages/zone.js/test/webdriver/test-es2015.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src='../../dist/zone-evergreen.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="thetext">Hello Zones!</div>
|
||||
</body>
|
||||
</html>
|
10
packages/zone.js/test/webdriver/test.html
Normal file
10
packages/zone.js/test/webdriver/test.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src='../../node_modules/core-js-bundle/index.js'></script>
|
||||
<script src='../../dist/zone.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="thetext">Hello Zones!</div>
|
||||
</body>
|
||||
</html>
|
30
packages/zone.js/test/webdriver/test.js
Normal file
30
packages/zone.js/test/webdriver/test.js
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
// TODO: @JiaLiPassion, try to add it into travis/saucelabs test after saucelabs support Firefox 52+
|
||||
// requirement, Firefox 52+, webdriver-manager 12.0.4+, selenium-webdriver 3.3.0+
|
||||
// test step,
|
||||
// webdriver-manager update
|
||||
// webdriver-manager start
|
||||
// http-server test/webdriver
|
||||
// node test/webdriver/test.js
|
||||
|
||||
// testcase1: removeEventHandler in firefox cross site context
|
||||
const webdriver = require('selenium-webdriver');
|
||||
const capabilities = webdriver.Capabilities.firefox();
|
||||
const driver = new webdriver.Builder()
|
||||
.usingServer('http://localhost:4444/wd/hub')
|
||||
.withCapabilities(capabilities)
|
||||
.build();
|
||||
driver.get('http://localhost:8080/test.html');
|
||||
driver.executeAsyncScript((cb) => {window.setTimeout(cb, 1000)});
|
||||
|
||||
// test case2 addEventHandler in firefox cross site context
|
||||
driver.findElement(webdriver.By.css('#thetext')).getText().then(function(text) {
|
||||
console.log(text);
|
||||
});
|
101
packages/zone.js/test/webdriver/test.sauce.es2015.js
Normal file
101
packages/zone.js/test/webdriver/test.sauce.es2015.js
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
const webdriverio = require('webdriverio');
|
||||
const desiredCapabilities = {
|
||||
android60: {
|
||||
deviceName: 'Android GoogleAPI Emulator',
|
||||
browserName: 'Chrome',
|
||||
platformName: 'Android',
|
||||
platformVersion: '6.0',
|
||||
deviceOrientation: 'portrait',
|
||||
appiumVersion: '1.12.1'
|
||||
},
|
||||
android71: {
|
||||
deviceName: 'Android GoogleAPI Emulator',
|
||||
browserName: 'Chrome',
|
||||
platformName: 'Android',
|
||||
platformVersion: '7.1',
|
||||
deviceOrientation: 'portrait',
|
||||
appiumVersion: '1.12.1'
|
||||
}
|
||||
};
|
||||
|
||||
const errors = [];
|
||||
const tasks = [];
|
||||
|
||||
if (process.env.TRAVIS) {
|
||||
process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
|
||||
}
|
||||
|
||||
Object.keys(desiredCapabilities).forEach(key => {
|
||||
console.log('begin webdriver test', key);
|
||||
if (process.env.TRAVIS) {
|
||||
desiredCapabilities[key]['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
|
||||
}
|
||||
const client = require('webdriverio').remote({
|
||||
user: process.env.SAUCE_USERNAME,
|
||||
key: process.env.SAUCE_ACCESS_KEY,
|
||||
host: 'localhost',
|
||||
port: 4445,
|
||||
desiredCapabilities: desiredCapabilities[key]
|
||||
});
|
||||
|
||||
const p = client.init()
|
||||
.timeouts('script', 60000)
|
||||
.url('http://localhost:8080/test/webdriver/test-es2015.html')
|
||||
.executeAsync(function(done) { window.setTimeout(done, 1000) })
|
||||
.execute(function() {
|
||||
const elem = document.getElementById('thetext');
|
||||
const zone = window['Zone'] ? Zone.current.fork({name: 'webdriver'}) : null;
|
||||
if (zone) {
|
||||
zone.run(function() {
|
||||
elem.addEventListener('click', function(e) {
|
||||
e.target.innerText = 'clicked' + Zone.current.name;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
elem.addEventListener('click', function(e) { e.target.innerText = 'clicked'; });
|
||||
}
|
||||
})
|
||||
.click('#thetext')
|
||||
.getText('#thetext')
|
||||
.then(
|
||||
(text => {
|
||||
if (text !== 'clickedwebdriver') {
|
||||
errors.push(`Env: ${key}, expected clickedwebdriver, get ${text}`);
|
||||
}
|
||||
}),
|
||||
(error) => { errors.push(`Env: ${key}, error occurs: ${error}`); })
|
||||
.end();
|
||||
tasks.push(p);
|
||||
});
|
||||
|
||||
function exit(exitCode) {
|
||||
const http = require('http');
|
||||
http.get('http://localhost:8080/close', () => { process.exit(exitCode); });
|
||||
}
|
||||
|
||||
Promise.all(tasks).then(() => {
|
||||
if (errors.length > 0) {
|
||||
let nonTimeoutError = false;
|
||||
errors.forEach(error => {
|
||||
console.log(error);
|
||||
if (error.toString().lastIndexOf('timeout') === -1) {
|
||||
nonTimeoutError = true;
|
||||
}
|
||||
});
|
||||
if (nonTimeoutError) {
|
||||
exit(1);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
});
|
112
packages/zone.js/test/webdriver/test.sauce.js
Normal file
112
packages/zone.js/test/webdriver/test.sauce.js
Normal file
@ -0,0 +1,112 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
const webdriverio = require('webdriverio');
|
||||
const desiredCapabilities = {
|
||||
firefox52Win7: {browserName: 'firefox', platform: 'Windows 7', version: '52'},
|
||||
firefox53Win7: {browserName: 'firefox', platform: 'Windows 7', version: '53'},
|
||||
edge14: {browserName: 'MicrosoftEdge', platform: 'Windows 10', version: '14.14393'},
|
||||
edge15: {browserName: 'MicrosoftEdge', platform: 'Windows 10', version: '15.15063'},
|
||||
chrome48: {browserName: 'chrome', version: '48'},
|
||||
safari8: {browserName: 'safari', platform: 'OS X 10.10', version: '8.0'},
|
||||
safari9: {browserName: 'safari', platform: 'OS X 10.11', version: '9.0'},
|
||||
safari10: {browserName: 'safari', platform: 'OS X 10.11', version: '10.0'},
|
||||
safari11: {browserName: 'safari', platform: 'macOS 10.13', version: '11.1'},
|
||||
/*ios84: {browserName: 'iphone', platform: 'OS X 10.10', version: '8.4'},*/
|
||||
ios10: {browserName: 'iphone', platform: 'OS X 10.10', version: '10.3'},
|
||||
ios11: {browserName: 'iphone', platform: 'OS X 10.12', version: '11.2'},
|
||||
/*
|
||||
ie9: {
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 2008',
|
||||
version: '9'
|
||||
},*/
|
||||
/*
|
||||
ie10: {
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 2012',
|
||||
version: '10'
|
||||
},*/
|
||||
ie11: {browserName: 'internet explorer', platform: 'Windows 10', version: '11'},
|
||||
// andriod44: {browserName: 'android', platform: 'Linux', version: '4.4'},
|
||||
android51: {browserName: 'android', platform: 'Linux', version: '5.1'},
|
||||
};
|
||||
|
||||
const errors = [];
|
||||
const tasks = [];
|
||||
|
||||
if (process.env.TRAVIS) {
|
||||
process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
|
||||
}
|
||||
|
||||
Object.keys(desiredCapabilities).forEach(key => {
|
||||
console.log('begin webdriver test', key);
|
||||
if (process.env.TRAVIS) {
|
||||
desiredCapabilities[key]['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
|
||||
}
|
||||
const client = require('webdriverio').remote({
|
||||
user: process.env.SAUCE_USERNAME,
|
||||
key: process.env.SAUCE_ACCESS_KEY,
|
||||
host: 'localhost',
|
||||
port: 4445,
|
||||
desiredCapabilities: desiredCapabilities[key]
|
||||
});
|
||||
|
||||
const p = client.init()
|
||||
.timeouts('script', 60000)
|
||||
.url('http://localhost:8080/test/webdriver/test.html')
|
||||
.executeAsync(function(done) { window.setTimeout(done, 1000) })
|
||||
.execute(function() {
|
||||
const elem = document.getElementById('thetext');
|
||||
const zone = window['Zone'] ? Zone.current.fork({name: 'webdriver'}) : null;
|
||||
if (zone) {
|
||||
zone.run(function() {
|
||||
elem.addEventListener('click', function(e) {
|
||||
e.target.innerText = 'clicked' + Zone.current.name;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
elem.addEventListener('click', function(e) { e.target.innerText = 'clicked'; });
|
||||
}
|
||||
})
|
||||
.click('#thetext')
|
||||
.getText('#thetext')
|
||||
.then(
|
||||
(text => {
|
||||
if (text !== 'clickedwebdriver') {
|
||||
errors.push(`Env: ${key}, expected clickedwebdriver, get ${text}`);
|
||||
}
|
||||
}),
|
||||
(error) => { errors.push(`Env: ${key}, error occurs: ${error}`); })
|
||||
.end();
|
||||
tasks.push(p);
|
||||
});
|
||||
|
||||
function exit(exitCode) {
|
||||
const http = require('http');
|
||||
http.get('http://localhost:8080/close', () => { process.exit(exitCode); });
|
||||
}
|
||||
|
||||
Promise.all(tasks).then(() => {
|
||||
if (errors.length > 0) {
|
||||
let nonTimeoutError = false;
|
||||
errors.forEach(error => {
|
||||
console.log(error);
|
||||
if (error.toString().lastIndexOf('timeout') === -1) {
|
||||
nonTimeoutError = true;
|
||||
}
|
||||
});
|
||||
if (nonTimeoutError) {
|
||||
exit(1);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user