Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3072938

Browse files
committed
chore(doc-gen): include source files from code.angularjs.org for production plnkr examples
1 parent 48f0957 commit 3072938

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

docs/app/e2e/app.scenario.js

+19
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ describe('docs.angularjs.org', function() {
4949
});
5050

5151

52+
it('should include the files for the embedded examples from the same domain', function() {
53+
browser.get('build/docs/index-production.html#!api/ng/directive/ngClick');
54+
55+
var origin = browser.executeScript('return document.location.origin;');
56+
57+
var exampleIFrame = element(by.name('example-ng-click'));
58+
59+
// This is technically an implementation detail, but if this changes, then there's a good
60+
// chance the deployment process changed
61+
expect(exampleIFrame.getAttribute('src')).toContain('examples/example-ng-click/index.html');
62+
63+
browser.switchTo().frame('example-ng-click');
64+
65+
var scriptEl = element(by.tagName('script'));
66+
67+
// Ensure the included file is from the same domain
68+
expect(scriptEl.getAttribute('src')).toContain(origin);
69+
});
70+
5271

5372
it('should be resilient to trailing slashes', function() {
5473
browser.get('build/docs/index-production.html#!/api/ng/function/angular.noop/');

docs/config/services/deployments/production.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ var angularCodeUrl = '//code.angularjs.org/';
77

88
var cdnUrl = googleCdnUrl + versionInfo.cdnVersion;
99

10-
// The plnkr examples must use the code.angularjs.org repo for the snapshot,
11-
// and the cdn for the tagged version and, if the build is not tagged, the currentVersion.
12-
//
13-
// The currentVersion may not be available on the cdn (e.g. if built locally, or hasn't been pushed
14-
// yet). This will lead to a 404, but this is preferable to loading a version with which the example
15-
// might not work (possibly in subtle ways).
16-
var examplesCdnUrl = versionInfo.currentVersion.isSnapshot ?
10+
// The "examplesCdnUrl" here applies to the examples when they are opened in plnkr.co.
11+
// The embedded examples instead always include the files from the *default* deployment,
12+
// to ensure that the source files are always available.
13+
// The plnkr examples must always use the code.angularjs.org source files.
14+
// We cannot rely on the CDN files here, because they are not deployed by the time
15+
// docs.angularjs.org and code.angularjs.org need them.
16+
var examplesDependencyPath = versionInfo.currentVersion.isSnapshot ?
1717
(angularCodeUrl + 'snapshot') :
18-
(googleCdnUrl + (versionInfo.currentVersion.version || versionInfo.currentVersion));
18+
(angularCodeUrl + (versionInfo.currentVersion.version || versionInfo.currentVersion.version));
1919

2020
module.exports = function productionDeployment(getVersion) {
2121
return {
2222
name: 'production',
2323
examples: {
2424
commonFiles: {
25-
scripts: [examplesCdnUrl + '/angular.min.js']
25+
scripts: [examplesDependencyPath + '/angular.min.js']
2626
},
27-
dependencyPath: examplesCdnUrl + '/'
27+
dependencyPath: examplesDependencyPath
2828
},
2929
scripts: [
3030
cdnUrl + '/angular.min.js',

0 commit comments

Comments
 (0)