2015-05-27 17:57:54 -04:00
|
|
|
/// <reference path="../../../angular2/typings/node/node.d.ts" />
|
|
|
|
/// <reference path="../../../angular2/typings/angular-protractor/angular-protractor.d.ts" />
|
|
|
|
/// <reference path="../../../angular2/typings/jasmine/jasmine.d.ts" />
|
|
|
|
|
2015-05-18 21:10:30 -04:00
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var validateFile = function() {
|
|
|
|
try {
|
|
|
|
var content = fs.readFileSync(browser.params.profileSavePath, 'utf8');
|
2015-06-01 19:17:28 -04:00
|
|
|
// TODO(hankduan): This check is not very useful. Ideally we want to
|
|
|
|
// validate that the file contains all the events that we are looking for.
|
|
|
|
// Pending on data transformer.
|
2015-05-18 21:10:30 -04:00
|
|
|
expect(content).toContain('forceGC');
|
|
|
|
// Delete file
|
|
|
|
fs.unlinkSync(browser.params.profileSavePath);
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code === 'ENOENT') {
|
|
|
|
// If files doesn't exist
|
|
|
|
console.error('Error: firefox extension did not save profile JSON');
|
|
|
|
} else {
|
|
|
|
console.error('Error: ' + err);
|
|
|
|
}
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('firefox extension', function() {
|
2015-06-01 19:17:28 -04:00
|
|
|
var TEST_URL = 'http://localhost:8001/examples/src/hello_world/index.html';
|
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
it('should measure performance', function() {
|
|
|
|
browser.sleep(3000); // wait for extension to load
|
2015-05-18 21:10:30 -04:00
|
|
|
|
2015-06-01 19:17:28 -04:00
|
|
|
browser.driver.get(TEST_URL);
|
2015-05-18 21:10:30 -04:00
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
browser.executeScript('window.startProfiler()')
|
|
|
|
.then(function() { console.log('started measuring perf'); });
|
2015-05-18 21:10:30 -04:00
|
|
|
|
|
|
|
browser.executeScript('window.forceGC()');
|
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
var script = 'window.stopAndRecord("' + browser.params.profileSavePath + '")';
|
|
|
|
browser.executeScript(script).then(function() { console.log('stopped measuring perf'); });
|
2015-05-18 21:10:30 -04:00
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
// wait for it to finish, then validate file.
|
|
|
|
browser.sleep(3000).then(validateFile);
|
2015-05-18 21:10:30 -04:00
|
|
|
})
|
|
|
|
});
|