angular-docs-cn/aio/src/index.html
Peter Bacon Darwin 441e01c568 fix(aio): simplify GaService to avoid e2e test failures
The GaService and the E2E specs were unnecessarily complicated and had
arbitrary async timeouts to ensure that the interplay between the GA
library code and the rest of the app worked correctly. This resulted
in potential flaky tests if the timeouts were not adequate; this was
experienced when Travis upgraded to Chrome 62.

The new approach is to block loading of the Analytics library altogether
if there is a `__e2e__` flag set in the `SessionStorage` of the browser.
It doesn't appear to be enough just to set the flag directly on the
window. I think this is because the window gets cleaned when navigation
occurs (but I am not certain).

The downside of this is that we had to add a small piece of extra logic
to the GA snippet in index.html; and we also had to switch from using
`<script async ...>` to a programmatic approach to loading the GA library
which prevents the browser from eagerly fetching the library. This may
be mitigated by adding it to the HTTP/2 push configuration of the Firebase
hosting.

Re-enables the test that was disabled in https://github.com/angular/angular/pull/19784

Closes #19785
2017-10-20 09:40:52 -07:00

92 lines
3.7 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Angular Docs</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/x-icon" href="assets/images/favicons/favicon.ico">
<link rel="icon" type="image/png" href="assets/images/favicons/favicon-32x32.png"
sizes="32x32">
<link rel="icon" type="image/png" href="assets/images/favicons/favicon-194x194.png"
sizes="194x194">
<link rel="icon" type="image/png" href="assets/images/favicons/favicon-96x96.png"
sizes="96x96">
<link rel="icon" type="image/png" href="assets/images/favicons/favicon-16x16.png"
sizes="16x16">
<link rel="apple-touch-icon" sizes="144x144" href="assets/images/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/images/favicons/apple-touch-icon-144x144.png">
<!-- NOTE: These need to be kept in sync with `ngsw-manifest.json`. -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- -->
<link rel="manifest" href="pwa-manifest.json">
<meta name="theme-color" content="#1976d2">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="translucent">
<!-- Google Analytics -->
<script>
// Note this is a customised version of the GA tracking snippet to aid e2e testing
// See the bit between /**/.../**/
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;/**/i.sessionStorage.__e2e__||/**/m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
</script>
<!-- End Google Analytics -->
<script>
if (window.document.documentMode) {
// polyfill IE11 in a blocking way
var s = document.createElement('script');
s.src = 'generated/ie-polyfills.min.js';
document.head.appendChild(s);
} else if (!Object.assign) {
// polyfill other non-evergreen browsers in a blocking way
var polyfillUrl = "https://cdn.polyfill.io/v2/polyfill.min.js?features=default,Array.prototype.find&flags=gated&unknown=polyfill";
// send a blocking XHR to fetch the polyfill
// then append it to the document so that its eval-ed synchronously
// this is required because the method used for IE is not reliable with other non-evergreen browsers
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", function() {
var s = document.createElement('script');
s.type = 'text/javascript';
var code = this.responseText;
s.appendChild(document.createTextNode(code));
document.head.appendChild(s);
});
xhr.open("GET", polyfillUrl, false);
xhr.send();
}
</script>
</head>
<body>
<aio-shell></aio-shell>
<noscript>
<div class="background-sky hero"></div>
<section id="intro">
<div class="hero-logo">
<img src="assets/images/logos/angular/angular.svg" width="250" height="250">
</div>
<div class="homepage-container">
<div class="hero-headline">One framework.<br>Mobile &amp; desktop.</div>
</div>
</section>
<h2 style="color: red; text-align: center; margin-top: -50px;">
<b><i>This website requires JavaScript.</i></b>
</h2>
</noscript>
</body>
</html>