Permalink
Browse files

Automated g4 rollback

*** Reason for rollback ***

problems have been fixed

*** Original change description ***

Automated g4 rollback

*** Reason for rollback ***

seems to cause problems

*** Original change description ***

In debug mode, prefer parallel script loading + source url injection
instead of serial script loading.
this time, with the deps updated

R=ssaviano
DELTA=44 (32 added, 3 deleted, 9 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6068


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2413 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent a085d39 commit 1283aefb81bce389bc825a352f5f2cfe094c11a8 nicksantos@google.com committed Jan 3, 2013
Showing with 37 additions and 12 deletions.
  1. +5 −5 closure/goog/deps.js
  2. +19 −3 closure/goog/module/moduleloader.js
  3. +13 −4 closure/goog/module/moduleloader_test.html
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -40,6 +40,7 @@ goog.require('goog.module.AbstractModuleLoader');
goog.require('goog.net.BulkLoader');
goog.require('goog.net.EventType');
goog.require('goog.net.jsloader');
+goog.require('goog.userAgent.product');
@@ -94,9 +95,19 @@ goog.module.ModuleLoader.prototype.debugMode_ = false;
goog.module.ModuleLoader.prototype.sourceUrlInjection_ = false;
+/**
+ * @return {boolean} Whether sourceURL affects stack traces.
+ * Chrome is currently the only browser that does this, but
+ * we believe other browsers are working on this.
+ */
+goog.module.ModuleLoader.supportsSourceUrlStackTraces = function() {
+ return goog.userAgent.product.CHROME;
+};
+
+
/**
* Gets the debug mode for the loader.
- * @return {boolean} debugMode Whether the debug mode is enabled.
+ * @return {boolean} Whether the debug mode is enabled.
*/
goog.module.ModuleLoader.prototype.getDebugMode = function() {
return this.debugMode_;
@@ -141,7 +152,9 @@ goog.module.ModuleLoader.prototype.setSourceUrlInjection = function(enabled) {
/** @return {boolean} Whether we're using source url injection. */
goog.module.ModuleLoader.prototype.usingSourceUrlInjection = function() {
- return this.sourceUrlInjection_;
+ return this.sourceUrlInjection_ ||
+ (this.getDebugMode() &&
+ goog.module.ModuleLoader.supportsSourceUrlStackTraces());
};
@@ -275,11 +288,14 @@ goog.module.ModuleLoader.prototype.downloadModules_ = function(
}
this.logger.info('downloadModules ids:' + ids + ' uris:' + uris);
- if (this.getDebugMode()) {
+ if (this.getDebugMode() &&
+ !this.usingSourceUrlInjection()) {
// In debug mode use <script> tags rather than XHRs to load the files.
// This makes it possible to debug and inspect stack traces more easily.
// It's also possible to use it to load JavaScript files that are hosted on
// another domain.
+ // The scripts need to load serially, so this is much slower than parallel
+ // script loads with source url injection.
goog.net.jsloader.loadMany(uris);
} else {
var loadStatus = this.loadingModulesStatus_[ids];
@@ -188,8 +188,17 @@
}
function testSourceInjection() {
- testCase.waitForAsync('wait for module B load');
moduleLoader.setSourceUrlInjection(true);
+ assertSourceInjection();
+}
+
+function testSourceInjectionViaDebugMode() {
+ moduleLoader.setDebugMode(true);
+ assertSourceInjection();
+}
+
+function assertSourceInjection() {
+ testCase.waitForAsync('wait for module B load');
moduleManager.execOnLoad('modB', function() {
testCase.continueTesting();
@@ -203,10 +212,10 @@
assertNotNull(ex);
- // Chrome is currently the only browser that uses sourceURL
- // when serializing stack traces.
- if (goog.userAgent.product.CHROME) {
+ if (goog.module.ModuleLoader.supportsSourceUrlStackTraces) {
assertContains('modB_1.js', ex.stack.toString());
+ } else {
+ assertNotContains('modB_1.js', ex.stack.toString());
}
});
}

0 comments on commit 1283aef

Please sign in to comment.