diff --git a/modules/angular2/src/facade/lang.es6 b/modules/angular2/src/facade/lang.es6
index 191367c468..f0c672f801 100644
--- a/modules/angular2/src/facade/lang.es6
+++ b/modules/angular2/src/facade/lang.es6
@@ -243,5 +243,9 @@ export function assertionsEnabled():boolean {
}
export function print(obj) {
- console.log(obj);
+ if (obj instanceof Error) {
+ console.log(obj.stack);
+ } else {
+ console.log(obj);
+ }
}
diff --git a/modules/examples/e2e_test/sourcemap/sourcemap_spec.es6 b/modules/examples/e2e_test/sourcemap/sourcemap_spec.es6
new file mode 100644
index 0000000000..7d35609620
--- /dev/null
+++ b/modules/examples/e2e_test/sourcemap/sourcemap_spec.es6
@@ -0,0 +1,41 @@
+var fs = require('fs');
+var sourceMap = require('source-map');
+
+describe('sourcemaps', function () {
+ var URL = 'examples/src/sourcemap/index.html';
+
+ it('should map sources', function() {
+ browser.get(URL);
+ // TODO(tbosch): Bug in ChromeDriver: Need to execute at least one command
+ // so that the browser logs can be read out!
+ browser.executeScript('1+1');
+ browser.manage().logs().get('browser').then(function(logs) {
+ var errorLine = null;
+ var errorColumn = null;
+ logs.forEach(function(log) {
+ var match = /Test\.run\s+\(.+:(\d+):(\d+)/m.exec(log.message);
+ if (match) {
+ errorLine = parseInt(match[1]);
+ errorColumn = parseInt(match[2]);
+ }
+ });
+
+ expect(errorLine).not.toBeNull();
+ expect(errorColumn).not.toBeNull();
+
+ var sourceMapData = fs.readFileSync(
+ 'dist/js/prod/es5/examples/src/sourcemap/index.js.map');
+ var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData));
+
+ var originalPosition = decoder.originalPositionFor({
+ line: errorLine,
+ column: errorColumn
+ });
+
+ var sourceCodeLines = fs.readFileSync('modules/examples/src/sourcemap/index.js',
+ {encoding: 'UTF-8'}).split('\n');
+ expect(sourceCodeLines[originalPosition.line - 1])
+ .toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
+ });
+ });
+});
diff --git a/modules/examples/src/sourcemap/index.html b/modules/examples/src/sourcemap/index.html
new file mode 100644
index 0000000000..1689e33399
--- /dev/null
+++ b/modules/examples/src/sourcemap/index.html
@@ -0,0 +1,9 @@
+
+
+
Sourcemaps
+
+ Please look into the console and check whether the stack trace is mapped
+ via source maps!
+ $SCRIPTS$
+
+
diff --git a/modules/examples/src/sourcemap/index.js b/modules/examples/src/sourcemap/index.js
new file mode 100644
index 0000000000..b4434cce8e
--- /dev/null
+++ b/modules/examples/src/sourcemap/index.js
@@ -0,0 +1,24 @@
+import { BaseException, print, CONST } from 'angular2/src/facade/lang';
+
+class TestAnnotation {
+ @CONST()
+ constructor() {}
+}
+
+// Use a class with an annotation,
+// as this is where we expect the most source code changes
+// through compilation.
+@TestAnnotation()
+class Test {
+ run() {
+ try {
+ throw new BaseException('Sourcemap test');
+ } catch (e) {
+ print(e);
+ }
+ }
+}
+
+export function main() {
+ new Test().run();
+}
diff --git a/package.json b/package.json
index 00d63856ff..43fe41d9bf 100644
--- a/package.json
+++ b/package.json
@@ -64,6 +64,7 @@
"protractor": "1.6.x",
"q": "^1.0.1",
"run-sequence": "^0.3.6",
+ "source-map": "^0.3.0",
"sprintf-js": "1.0.*",
"through2": "^0.6.1",
"yargs": "2.3.*"
diff --git a/protractor-e2e-dart2js.conf.js b/protractor-e2e-dart2js.conf.js
index 5cdf1f6f72..378b154177 100644
--- a/protractor-e2e-dart2js.conf.js
+++ b/protractor-e2e-dart2js.conf.js
@@ -3,4 +3,4 @@ config.baseUrl = 'http://localhost:8002/';
// TODO: remove this line when largetable dart has been added
config.exclude = config.exclude || [];
config.exclude.push('dist/js/cjs/benchmarks_external/e2e_test/largetable_spec.js');
-
+config.exclude.push('dist/js/cjs/examples/e2e_test/sourcemap/sourcemap_spec.js');
diff --git a/protractor-shared.js b/protractor-shared.js
index 0c6a504534..eb5c7e4470 100644
--- a/protractor-shared.js
+++ b/protractor-shared.js
@@ -35,7 +35,8 @@ var POSSIBLE_CAPS = {
'args': ['--js-flags=--expose-gc']
},
loggingPrefs: {
- performance: 'ALL'
+ performance: 'ALL',
+ browser: 'ALL'
}
},
ChromeDesktop: {
@@ -44,7 +45,8 @@ var POSSIBLE_CAPS = {
'args': ['--js-flags=--expose-gc']
},
loggingPrefs: {
- performance: 'ALL'
+ performance: 'ALL',
+ browser: 'ALL'
}
},
ChromeAndroid: {
@@ -54,7 +56,8 @@ var POSSIBLE_CAPS = {
'args': ['--js-flags=--expose-gc']
},
loggingPrefs: {
- performance: 'ALL'
+ performance: 'ALL',
+ browser: 'ALL'
}
}
};