testLoadMultipleWhenPreloadingSameModules() {
    const mm = getModuleManager({'a': [], 'b': ['d'], 'c': [], 'd': []});
    mm.setLoader(createSuccessfulBatchLoader(mm));
    mm.setBatchModeEnabled(true);

    const origBeforeLoadModuleCode = mm.beforeLoadModuleCode;
    const origSetLoaded = mm.setLoaded;
    const calls = {'c': 0, 'd': 0};
    mm.beforeLoadModuleCode = (id) => {
      calls[id]++;
      origBeforeLoadModuleCode.call(mm, id);
    };
    let setLoadedCalls = 0;
    mm.setLoaded = () => {
      setLoadedCalls++;
      origSetLoaded.call(mm);
    };

    let calledBack = false;
    let error = null;
    let calledBack2 = false;
    let error2 = null;

    mm.preloadModule('c', 2);
    mm.preloadModule('d', 3);
    assertFalse(
        'module "c" should not be loading yet', mm.isModuleLoading('c'));
    assertFalse(
        'module "d" should not be loading yet', mm.isModuleLoading('d'));
    clock.tick(2);
    assertTrue('module "c" should now be loading', mm.isModuleLoading('c'));
    clock.tick(1);
    assertTrue('module "d" should now be loading', mm.isModuleLoading('d'));

    const dMap = mm.loadMultiple(['c', 'd']);
    dMap['c'].then(
        (ctx) => {
          calledBack = true;
        },
        (err) => {
          error = err;
        });
    dMap['d'].then(
        (ctx) => {
          calledBack2 = true;
        },
        (err) => {
          error2 = err;
        });

    assertTrue('module "c" should still be loading', mm.isModuleLoading('c'));
    clock.tick(4);
    assertFalse('module "c" should be done loading', mm.isModuleLoading('c'));
    assertTrue('module "d" should still be loading', mm.isModuleLoading('d'));
    clock.tick(5);
    assertFalse('module "d" should be done loading', mm.isModuleLoading('d'));

    assertTrue(calledBack);
    assertTrue(calledBack2);

    assertEquals(
        'beforeLoad should only be called once for "c"', 1, calls['c']);
    assertEquals(
        'beforeLoad should only be called once for "d"', 1, calls['d']);
    assertEquals('setLoaded should have been called twice', 2, setLoadedCalls);

    assertNull(error);
    assertNull(error2);
  }
Tests that the deferred is still called when loadMultiple loads modules
that are already preloading.