Example #1
0
 /**
  * Starts measuring
  */
 beginMeasure(): Promise<any> {
   return PromiseWrapper.all(this._metrics.map(metric => metric.beginMeasure()));
 }
Example #2
0
 supports(promise): boolean { return PromiseWrapper.isPromise(promise); }
Example #3
0
function AsyncParentLoader() {
  return PromiseWrapper.resolve(DummyParentComp);
}
Example #4
0
 ref.spy('routerCanReuse').andCallFake((_) => PromiseWrapper.resolve(false));
Example #5
0
 executeScript(script): Promise<string> { return PromiseWrapper.resolve('someUserAgent'); }
Example #6
0
  _inlineImports(cssText: string, baseUrl: string, inlinedUrls: List<string>): Promise<string>|string {
    var partIndex = 0;
    var parts = StringWrapper.split(cssText, _importRe);

    if (parts.length === 1) {
      // no @import rule found, return the original css
      return cssText;
    }

    var promises = [];

    while (partIndex < parts.length - 1) {
      // prefix is the content before the @import rule
      var prefix = parts[partIndex];
      // rule is the parameter of the @import rule
      var rule = parts[partIndex + 1];
      var url = _extractUrl(rule);
      if (isPresent(url)) {
        url = this._urlResolver.resolve(baseUrl, url);
      }
      var mediaQuery = _extractMediaQuery(rule);
      var promise;

      if (isBlank(url)) {
        promise = PromiseWrapper.resolve(`/* Invalid import rule: "@import ${rule};" */`);
      } else if (ListWrapper.contains(inlinedUrls, url)) {
        // The current import rule has already been inlined, return the prefix only
        // Importing again might cause a circular dependency
        promise = PromiseWrapper.resolve(prefix);
      } else {
        ListWrapper.push(inlinedUrls, url);
        promise = PromiseWrapper.then(
          this._xhr.get(url),
          (css) => {
            // resolve nested @import rules
            css = this._inlineImports(css, url, inlinedUrls);
            if (PromiseWrapper.isPromise(css)) {
              // wait until nested @import are inlined
              return css.then((css) => {
                return prefix + this._transformImportedCss(css, mediaQuery, url) + '\n'
              }) ;
            } else {
              // there are no nested @import, return the css
              return prefix + this._transformImportedCss(css, mediaQuery, url) + '\n';
            }
          },
          (error) => `/* failed to import ${url} */\n`
        );
      }
      ListWrapper.push(promises, promise);
      partIndex += 2;
    }

    return PromiseWrapper.all(promises).then(function (cssParts) {
      var cssText = cssParts.join('');
      if (partIndex < parts.length) {
        // append then content located after the last @import rule
        cssText += parts[partIndex];
      }
      return cssText;
    });
  }
Example #7
0
 reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]): Promise<any[]> {
   return PromiseWrapper.all(
       this._reporters.map(reporter => reporter.reportSample(completeSample, validSample)));
 }
 routerOnActivate(next: ComponentInstruction, prev: ComponentInstruction): Promise<any> {
   completer = PromiseWrapper.completer();
   logHook('parent activate', next, prev);
   return completer.promise;
 }
 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction): Promise<boolean> {
   completer = PromiseWrapper.completer();
   logHook('routerCanDeactivate', next, prev);
   return completer.promise;
 }
Example #10
0
 reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]):
     Promise<{[key: string]: any}> {
   return PromiseWrapper.resolve(
       {'id': this._id, 'completeSample': completeSample, 'validSample': validSample});
 }
Example #11
0
// Schedules a microtasks (using a resolved promise .then())
function microTask(fn: Function): void {
  PromiseWrapper.resolve(null).then((_) => { fn(); });
}
Example #12
0
 reportMeasureValues(values: MeasureValues): Promise<{[key: string]: any}> {
   return PromiseWrapper.resolve({'id': this._id, 'values': values});
 }
 .toValue((filename, content) => {
   loggedFile = {'filename': filename, 'content': content};
   return PromiseWrapper.resolve(null);
 })
Example #14
0
 /**
  * Ends measuring and reports the data
  * since the begin call.
  * @param restart: Whether to restart right after this.
  */
 endMeasure(restart: boolean): Promise<{[key: string]: any}> {
   return PromiseWrapper.all(this._metrics.map(metric => metric.endMeasure(restart)))
       .then(values => mergeStringMaps(values));
 }
Example #15
0
 PromiseWrapper.resolve(null).then((_) => {
   log.add(1);
   PromiseWrapper.resolve(null).then((_) => log.add(2));
 });
 routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction): Promise<any> {
   completer = PromiseWrapper.completer();
   logHook('routerCanReuse', next, prev);
   return completer.promise;
 }
Example #17
0
 fakeAsync(() => {
   PromiseWrapper.resolve(null).then((_) => { throw new BaseException('async'); });
   flushMicrotasks();
 })();
Example #18
0
 _errorHandler(key: Key, e, stack): Promise<any> {
   if (e instanceof AbstractBindingError) e.addKey(key);
   return PromiseWrapper.reject(e, stack);
 }
Example #19
0
 reportMeasureValues(values: MeasureValues): Promise<any[]> {
   return PromiseWrapper.all(
       this._reporters.map(reporter => reporter.reportMeasureValues(values)));
 }
Example #20
0
 sample(): Promise<SampleState> { return PromiseWrapper.resolve(23); }
Example #21
0
function loader(): Promise<Type> {
  return PromiseWrapper.resolve(DummyComponent);
}
 .andCallFake((args: UiArguments, returnType: Type) => {
   if (args.method === 'getLocation') {
     return PromiseWrapper.resolve(loc);
   }
 });
Example #23
0
 ref.spy('activate').andCallFake((_) => PromiseWrapper.resolve(true));
Example #24
0
 TimerWrapper.setTimeout(() => {
   log.add('timer');
   PromiseWrapper.resolve(null).then((_) => log.add('t microtask'));
 }, 9);
Example #25
0
 sample(): Promise<SampleState> { return PromiseWrapper.resolve(new SampleState([], [])); }
Example #26
0
 var id = TimerWrapper.setInterval(() => {
   log.add('periodic timer');
   PromiseWrapper.resolve(null).then((_) => log.add('pt microtask'));
 }, 10);
 executeScript(script) {
   this._log.push(['executeScript', script]);
   return PromiseWrapper.resolve(null);
 }
Example #28
0
 fakeAsync(() => { PromiseWrapper.resolve(null).then(_ => { thenRan = true; }); })();
Example #29
0
function AsyncChildLoader() {
  return PromiseWrapper.resolve(DummyCompB);
}
Example #30
0
 compile(component) {
   var protoView = this._compile(this._bindDirective(component));
   return PromiseWrapper.isPromise(protoView) ? protoView : PromiseWrapper.resolve(protoView);
 }