File: base_debug_loader_test.js

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (707 lines) | stat: -rw-r--r-- 20,072 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


/**
 * @fileoverview Unit tests for Closure's base.js that require debug loading.
 * @suppress {missingRequire}
 */

goog.provide('goog.baseDebugLoaderTest');

goog.setTestOnly('goog.baseDebugLoaderTest');

// Used to test dynamic loading works, see testRequire*
goog.require('goog.Timer');
goog.require('goog.dom');
goog.require('goog.functions');
goog.require('goog.object');
goog.require('goog.test_module');
goog.require('goog.testing.PropertyReplacer');
goog.require('goog.testing.jsunit');

// NOTE: using computed properties to avoid compiler checks
const earlyTestModuleGet = goog['module'].get('goog.test_module');

var stubs = new goog.testing.PropertyReplacer();
var originalGoogBind = goog.bind;
var autoLoadDep = true;

/**
 * @param {string} path
 * @param {string} relativePath
 * @param {!Array<string>} provides
 * @param {!Array<string>} requires
 * @param {!Object<string, string>} loadFlags
 * @struct @constructor
 * @extends {goog.Dependency}
 */
function FakeDependency(path, relativePath, provides, requires, loadFlags) {
  FakeDependency.base(
      this, 'constructor', path, relativePath, provides, requires, loadFlags);
  this.loadCalled = false;
}
goog.inherits(FakeDependency, goog.Dependency);


/**
 * @override
 * @suppress {missingProperties,checkTypes}
 */
FakeDependency.prototype.load = function(controller) {
  this.markLoaded = function() {
    delete this.markLoaded;
    controller.loaded();
  };

  this.loadCalled = true;
  if (autoLoadDep) {
    this.markLoaded(controller);
  }
};


/**
 * @struct @constructor
 * @extends {goog.DependencyFactory}
 * @suppress {checkTypes}
 */
function FakeDependencyFactory() {
  this.realFactory = new goog.DependencyFactory();
}
goog.inherits(FakeDependencyFactory, goog.DependencyFactory);


/** @override */
FakeDependencyFactory.prototype.createDependency = function(
    path, relativePath, provides, requires, loadFlags) {
  var dep =
      new FakeDependency(path, relativePath, provides, requires, loadFlags);
  testDependencies.push(dep);
  realDependencies.push(this.realFactory.createDependency(
      path, relativePath, provides, requires, loadFlags));
  return dep;
};


var testDependencies = [];
var realDependencies = [];

// Avoid the compiler checks on goog.addDependency
const addDependency = goog.addDependency;


function setUpPage() {
  goog.global['CLOSURE_NO_DEPS'] = true;
}


/** @suppress {visibility,const} */
function setUp() {
  autoLoadDep = true;
  testDependencies = [];
  realDependencies = [];
  goog.debugLoader_ = new goog.DebugLoader_();
  goog.setDependencyFactory(new FakeDependencyFactory());
}


function tearDown() {
  // Use computed property here to avoid the compiler check that the value
  // is valid.
  goog['setCssNameMapping'](undefined);
  stubs.reset();
  goog.bind = originalGoogBind;
}

/** @suppress {constantProperty,visibility,checkTypes} */
function testInHtmlDocument() {
  var savedGoogGlobal = goog.global;
  try {
    goog.global = {};
    assertFalse(goog.inHtmlDocument_());
    goog.global.document = {};
    assertFalse(goog.inHtmlDocument_());
    goog.global.document.write = function() {};
    assertTrue(goog.inHtmlDocument_());
  } finally {
    // Restore context to respect other tests.
    goog.global = savedGoogGlobal;
  }
}

/** @suppress {constantProperty,missingRequire,visibility,checkTypes} */
function testLoadInNonHtmlNotThrows() {
  var savedGoogGlobal = goog.global;
  try {
    goog.global = {};
    goog.global.document = {};
    assertFalse(goog.inHtmlDocument_());
    // The goog code which is executed at load.
    goog.findBasePath_();
    goog.setDependencyFactory(new goog.DependencyFactory());
    addDependency('loadInNonHtmlNotThrows', ['load.InNonHtmlNotThrows'], []);
    var require = goog.require;
    require('load.InNonHtmlNotThrows');
  } finally {
    // Restore context to respect other tests.
    goog.global = savedGoogGlobal;
  }
}

/** @suppress {constantProperty,visibility,checkTypes} */
function testLoadBaseWithQueryParamOk() {
  var savedGoogGlobal = goog.global;
  try {
    goog.global = {};
    goog.global.document = {
      write: () => {},
      getElementsByTagName:
          goog.functions.constant([{src: '/path/to/base.js?zx=5'}])
    };
    assertTrue(goog.inHtmlDocument_());
    goog.findBasePath_();
    assertEquals('/path/to/', goog.basePath);
  } finally {
    // Restore context to respect other tests.
    goog.global = savedGoogGlobal;
  }
}

/** @suppress {constantProperty,visibility,checkTypes} */
function testLoadBaseFromGlobalVariableOk() {
  var savedGoogGlobal = goog.global;
  try {
    goog.global = {};
    goog.global.document = {
      write: () => {},
      getElementsByTagName:
          goog.functions.constant([{src: '/path/to/base.js?zx=5'}])
    };
    goog.global.CLOSURE_BASE_PATH = '/from/constant/';
    goog.findBasePath_();
    assertEquals(goog.global.CLOSURE_BASE_PATH, goog.basePath);
  } finally {
    // Restore context to respect other tests.
    goog.global = savedGoogGlobal;
  }
}

/** @suppress {constantProperty,visibility,checkTypes} */
function testLoadBaseFromGlobalVariableDOMClobbered() {
  var savedGoogGlobal = goog.global;
  try {
    goog.global = {};
    goog.global.document = {
      write: () => {},
      getElementsByTagName:
          goog.functions.constant([{src: '/path/to/base.js?zx=5'}])
    };
    // Make goog.global.CLOSURE_BASE_PATH an object with a toString, like
    // it would be if it were a DOM clobbered HTMLElement.
    goog.global.CLOSURE_BASE_PATH = {};
    goog.global.CLOSURE_BASE_PATH.toString = function() {
      return '/from/constant/';
    };
    goog.findBasePath_();
    assertEquals('/path/to/', goog.basePath);
  } finally {
    // Restore context to respect other tests.
    goog.global = savedGoogGlobal;
  }
}

/** @suppress {constantProperty,visibility,checkTypes} */
function testLoadBaseFromCurrentScriptIgnoringOthers() {
  var savedGoogGlobal = goog.global;
  try {
    goog.global = {};
    goog.global.document = {
      write: () => {},
      currentScript: {src: '/currentScript/base.js?zx=5'},
      getElementsByTagName:
          goog.functions.constant([{src: '/path/to/base.js?zx=5'}])
    };
    goog.findBasePath_();
    assertEquals('/currentScript/', goog.basePath);
  } finally {
    // Restore context to respect other tests.
    goog.global = savedGoogGlobal;
  }
}

/** @suppress {undefinedVars,checkTypes} testDep */
function testAddDependency() {
  addDependency('foo.js', ['testDep.foo'], ['testDep.bar']);

  // alias to avoid the being picked up by the deps scanner.
  var provide = goog.provide;

  provide('testDep.bar');

  // To differentiate this call from the real one.
  var require = goog.require;

  // this used to throw an exception
  require('testDep.foo');

  assertTrue(goog.isObject(testDep.bar));

  // Unset provided namespace so the test can be re-run.
  testDep = undefined;
}


/**
 * Asserts all test deps up to and including the expected index have loaded,
 * and anything past that has not.
 *
 * @param {number} expected
 */
function assertLoaded(expected) {
  for (var i = 0; i < testDependencies.length; i++) {
    assertEquals(expected >= i, testDependencies[i].loadCalled);
  }
}


/**
 * @param {!goog.Dependency} dep
 * @param {string} relPath
 * @param {!Array<string>} provides
 * @param {!Array<string>} requires
 * @param {!Object<string, string>} loadFlags
 */
function assertDepData(dep, relPath, provides, requires, loadFlags) {
  assertEquals(relPath, dep.relativePath);
  assertArrayEquals(provides, dep.provides);
  assertArrayEquals(requires, dep.requires);
  assertTrue(goog.object.equals(loadFlags, dep.loadFlags));
}


function testAddDependencyModule() {
  addDependency('mod.js', ['testDep.mod'], [], true);
  addDependency('empty.js', ['testDep.empty'], [], {});
  addDependency('mod-goog.js', ['testDep.goog'], [], {'module': 'goog'});

  // To differentiate this call from the real one.
  var require = goog.require;

  require('testDep.mod');
  assertLoaded(0);
  assertDepData(
      realDependencies[0], 'mod.js', ['testDep.mod'], [], {'module': 'goog'});
  assertTrue(realDependencies[0] instanceof goog.GoogModuleDependency);

  require('testDep.empty');
  assertLoaded(1);
  assertDepData(realDependencies[1], 'empty.js', ['testDep.empty'], [], {});
  assertTrue(realDependencies[0] instanceof goog.Dependency);

  require('testDep.goog');
  assertLoaded(2);
  assertDepData(
      realDependencies[2], 'mod-goog.js', ['testDep.goog'], [],
      {'module': 'goog'});
  assertTrue(realDependencies[2] instanceof goog.GoogModuleDependency);

  // Unset provided namespace so the test can be re-run.
  testDep = undefined;
}


function testAddDependencyEs6Module() {
  addDependency('mod-es6.js', ['testDep.es6'], [], {'module': 'es6'});

  // To differentiate this call from the real one.
  var require = goog.require;

  require('testDep.es6');
  assertLoaded(0);
  assertDepData(
      realDependencies[0], 'mod-es6.js', ['testDep.es6'], [],
      {'module': 'es6'});
  assertTrue(realDependencies[0] instanceof goog.Es6ModuleDependency);
}


async function testBootstrap() {
  addDependency('a.js', ['a'], [], {});
  addDependency('b.js', ['b'], ['a'], {});
  addDependency('c.js', ['c'], [], {});

  assertEquals(3, testDependencies.length);

  await new Promise((resolve, reject) => {
    goog.bootstrap(['b', 'c'], function() {
      resolve();
    });
  });

  for (var i = 0; i < testDependencies.length; i++) {
    assertTrue(testDependencies[i].loadCalled);
  }
}


/** @suppress {missingProperties} */
async function testBootstrapDelayLoadingDep() {
  autoLoadDep = false;

  addDependency('a.js', ['a'], [], {});
  addDependency('b.js', ['b'], ['a'], {});
  addDependency('c.js', ['c'], [], {});

  assertEquals(3, testDependencies.length);

  let bootstrapped = false;
  goog.bootstrap(['b', 'c'], () => {
    bootstrapped = true;
  });

  for (var i = 0; i < testDependencies.length; i++) {
    assertTrue(testDependencies[i].loadCalled);
  }
  assertFalse(bootstrapped);

  // Loading shallow deps should do nothing.
  testDependencies[0].markLoaded();
  // Loading one of the two requested deps shouldn't call the function.
  testDependencies[2].markLoaded();

  await new Promise(resolve => setTimeout(resolve, 50));

  assertFalse(bootstrapped);
  testDependencies[1].markLoaded();
  assertFalse(bootstrapped);

  // Await setTimeout so we enter the macrotask queue (goog.boostrap uses
  // setTimeout, which is a macrotask. Native Promises (non-polyfill) are
  // microtasks and would resolve before macrotasks.
  await new Promise(resolve => setTimeout(resolve, 0));

  assertTrue(bootstrapped);
}


//=== tests for Provide logic ===

/** @suppress {missingProperties} */
function testProvide() {
  // alias to avoid the being picked up by the deps scanner.
  const provide = goog.provide;

  provide('goog.test.name.space');
  assertNotUndefined('provide failed: goog.test', goog.test);
  assertNotUndefined('provide failed: goog.test.name', goog.test.name);
  assertNotUndefined(
      'provide failed: goog.test.name.space', goog.test.name.space);

  // ensure that providing 'goog.test.name' doesn't throw an exception
  provide('goog.test');
  provide('goog.test.name');
  delete goog.test;
}


// "watch" is a native member of Object.prototype on Firefox
// Ensure it can still be added as a namespace
/** @suppress {missingProperties} */
function testProvideWatch() {
  // alias to avoid the being picked up by the deps scanner.
  const provide = goog.provide;

  provide('goog.yoddle.watch');
  assertNotUndefined('provide failed: goog.yoddle.watch', goog.yoddle.watch);
  delete goog.yoddle;
}

/** @suppress {missingProperties} */
function testProvideStrictness() {
  // alias to avoid the being picked up by the deps scanner.
  const provide = goog.provide;

  provide('goog.xy');
  assertProvideFails('goog.xy');

  provide('goog.xy.z');
  assertProvideFails('goog.xy');

  window['goog']['xyz'] = 'Bob';
  assertProvideFails('goog.xyz');

  delete goog.xy;
  delete goog.xyz;
}

/** @param {?} namespace */
function assertProvideFails(namespace) {
  assertThrows(
      'goog.provide(' + namespace + ') should have failed',
      goog.partial(goog.provide, namespace));
}


/** @suppress {visibility} */
function testIsProvided() {
  // alias to avoid the being picked up by the deps scanner.
  const provide = goog.provide;

  provide('goog.explicit');
  assertTrue(goog.isProvided_('goog.explicit'));
  provide('goog.implicit.explicit');
  assertFalse(goog.isProvided_('goog.implicit'));
  assertTrue(goog.isProvided_('goog.implicit.explicit'));
}


//=== tests for Require logic ===

function testRequireClosure() {
  assertNotUndefined('goog.Timer should be available', goog.Timer);
  /** @suppress {missingRequire} */
  assertNotUndefined(
      'goog.events.EventTarget should be available', goog.events.EventTarget);
}

function testRequireWithExternalDuplicate() {
  // alias to avoid the being picked up by the deps scanner.
  const provide = goog.provide;

  // Do a provide without going via goog.require. Then goog.require it
  // indirectly and ensure it doesn't cause a duplicate script.
  addDependency('dup.js', ['dup.base'], []);
  addDependency('dup-child.js', ['dup.base.child'], ['dup.base']);
  provide('dup.base');

  stubs.set(goog, 'isDocumentFinishedLoading_', false);
  stubs.set(goog.global, 'CLOSURE_IMPORT_SCRIPT', function(src) {
    if (src == goog.basePath + 'dup.js') {
      fail('Duplicate script written!');
    } else if (src == goog.basePath + 'dup-child.js') {
      // Allow expected script.
      return true;
    } else {
      // Avoid affecting other state.
      return false;
    }
  });

  // To differentiate this call from the real one.
  const require = goog.require;
  require('dup.base.child');
}

/**
 * @suppress {undefinedVars,visibility,missingProperties} 'far' defined by
 * goog.provide
 */
function testGoogRequireCheck() {
  // alias to avoid the being picked up by the deps scanner.
  const provide = goog.provide;

  stubs.set(goog, 'ENABLE_DEBUG_LOADER', true);
  stubs.set(goog, 'useStrictRequires', true);
  stubs.set(goog, 'implicitNamespaces_', {});

  // Aliased so that build tools do not mistake this for an actual call.
  const require = goog.require;
  // should not throw
  require('far.outnotprovided');

  assertUndefined(goog.global.far);
  assertEvaluatesToFalse(goog.getObjectByName('far.out'));
  assertObjectEquals({}, goog.implicitNamespaces_);
  assertFalse(goog.isProvided_('far.out'));

  provide('far.out');

  assertNotUndefined(far.out);
  assertEvaluatesToTrue(goog.getObjectByName('far.out'));
  assertObjectEquals({'far': true}, goog.implicitNamespaces_);
  assertTrue(goog.isProvided_('far.out'));

  goog.global.far.out = 42;
  assertEquals(42, goog.getObjectByName('far.out'));
  assertTrue(goog.isProvided_('far.out'));

  // Empty string should be allowed.
  goog.global.far.out = '';
  assertEquals('', goog.getObjectByName('far.out'));
  assertTrue(goog.isProvided_('far.out'));

  // Null or undefined are not allowed.
  goog.global.far.out = null;
  assertNull(goog.getObjectByName('far.out'));
  assertFalse(goog.isProvided_('far.out'));

  goog.global.far.out = undefined;
  assertNull(goog.getObjectByName('far.out'));
  assertFalse(goog.isProvided_('far.out'));

  stubs.reset();
  delete goog.global.far;
}


/** @suppress {visibility} */
function testGetScriptNonce() {
  // clear nonce cache for test.
  const origNonce = goog.getScriptNonce_();
  goog.cspNonce_ = null;
  const nonce = origNonce ? origNonce : 'ThisIsANonceThisIsANonceThisIsANonce';
  const script = goog.dom.createElement(goog.dom.TagName.SCRIPT);
  script.setAttribute('nonce', 'invalid nonce');
  document.body.appendChild(script);

  try {
    assertEquals(origNonce, goog.getScriptNonce_());
    // clear nonce cache for test.
    goog.cspNonce_ = null;
    script.nonce = nonce;
    assertEquals(nonce, goog.getScriptNonce_());
  } finally {
    goog.dom.removeNode(script);
  }
}

/** @suppress {checkTypes} */
function testBaseClass() {
  function A(x, y) {
    this.foo = x + y;
  }

  function B(x, y) {
    B.base(this, 'constructor', x, y);
    this.foo += 2;
  }
  goog.inherits(B, A);

  function C(x, y) {
    C.base(this, 'constructor', x, y);
    this.foo += 4;
  }
  goog.inherits(C, B);

  function D(x, y) {
    D.base(this, 'constructor', x, y);
    this.foo += 8;
  }
  goog.inherits(D, C);

  assertEquals(15, (new D(1, 0)).foo);
  assertEquals(16, (new D(1, 1)).foo);
  assertEquals(16, (new D(2, 0)).foo);
  assertEquals(7, (new C(1, 0)).foo);
  assertEquals(3, (new B(1, 0)).foo);
}

/** @suppress {checkTypes} */
function testBaseMethodAndBaseCtor() {
  // This will fail on FF4.0 if the following bug is not fixed:
  // https://bugzilla.mozilla.org/show_bug.cgi?id=586482
  function A(x, y) {
    this.foo(x, y);
  }
  A.prototype.foo = function(x, y) {
    this.bar = x + y;
  };

  function B(x, y) {
    B.base(this, 'constructor', x, y);
  }
  goog.inherits(B, A);
  B.prototype.foo = function(x, y) {
    B.base(this, 'foo', x, y);
    this.bar = this.bar * 2;
  };

  assertEquals(14, new B(3, 4).bar);
}


//=== tests for bind() and friends ===

// Function.prototype.bind and Function.prototype.partial are purposefullly
// not defined in open sourced Closure.  These functions sniff for their
// presence.

var foo = 'global';

/**
 * @param {?} arg1
 * @param {?} arg2
 * @return {?}
 * @suppress {checkTypes}
 */
function getFoo(arg1, arg2) {
  return {foo: this.foo, arg1: arg1, arg2: arg2};
}


/** @suppress {checkTypes} */
function testBindWithoutObj() {
  if (Function.prototype.bind) {
    assertEquals(foo, getFoo.bind()().foo);
  }
}

/** @suppress {checkTypes} */
function testBindWithNullObj() {
  if (Function.prototype.bind) {
    assertEquals(foo, getFoo.bind(null)().foo);
  }
}


// Validate the behavior of goog.module when used from traditional files.
/** @suppress {missingProperties} namespaces */
function testGoogModuleGet() {
  // assert that goog.module doesn't modify the global namespace
  assertUndefined(
      'module failed to protect global namespace: ' +
          'goog.test_module_dep',
      goog.test_module_dep);

  // assert that goog.module with goog.module.declareLegacyNamespace is
  // present.
  assertNotUndefined(
      'module failed to declare global namespace: ' +
          'goog.test_module',
      goog.test_module);

  // assert that a require'd goog.module is available immediately after the
  // goog.require call.
  assertNotUndefined(
      'module failed to protect global namespace: ' +
          'goog.test_module_dep',
      earlyTestModuleGet);

  // assert that an non-existent module request doesn't throw and returns
  // null.
  // NOTE: using computed properties to avoid compiler checks
  assertEquals(null, goog['module'].get('unrequired.module.id'));

  // Validate the module exports
  const testModuleExports = goog.module.get('goog.test_module');
  assertTrue(typeof testModuleExports === 'function');

  // Test that any escaping of </script> in test files is correct. Escape the
  // / in </script> here so that any such code does not affect it here.
  assertEquals('<\/script>', testModuleExports.CLOSING_SCRIPT_TAG);

  // Validate that the module exports object has not changed
  assertEquals(earlyTestModuleGet, testModuleExports);
}