Skip to content

Commit 07aef32

Browse files
Merge pull request #119 from angular/master
Check if umask is 000 in brew doctor
2 parents 8528a7e + 4e372d9 commit 07aef32

File tree

9 files changed

+243
-95
lines changed

9 files changed

+243
-95
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ If you rely on the $modelValue validation, you can overwrite the `min`/`max` val
746746
link: function(scope, element, attrs, ctrl) {
747747
var maxValidator = ctrl.$validators.max;
748748

749-
ctrk.$validators.max = function(modelValue, viewValue) {
749+
ctrl.$validators.max = function(modelValue, viewValue) {
750750
return maxValidator(modelValue, modelValue);
751751
};
752752
}
@@ -1579,7 +1579,7 @@ If you rely on the $modelValue validation, you can overwrite the `min`/`max` val
15791579
link: function(scope, element, attrs, ctrl) {
15801580
var maxValidator = ctrl.$validators.max;
15811581

1582-
ctrk.$validators.max = function(modelValue, viewValue) {
1582+
ctrl.$validators.max = function(modelValue, viewValue) {
15831583
return maxValidator(modelValue, modelValue);
15841584
};
15851585
}

docs/content/guide/migration.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ custom directive, as seen in the following example directive definition object:
148148
link: function(scope, element, attrs, ctrl) {
149149
var maxValidator = ctrl.$validators.max;
150150

151-
ctrk.$validators.max = function(modelValue, viewValue) {
151+
ctrl.$validators.max = function(modelValue, viewValue) {
152152
return maxValidator(modelValue, modelValue);
153153
};
154154
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@
8383
"npm-run": "^4.1.0",
8484
"open-sans-fontface": "^1.4.0",
8585
"promises-aplus-tests": "~2.1.0",
86-
"protractor": "^5.1.2",
86+
"protractor": "^5.4.1",
8787
"q": "~1.0.0",
8888
"q-io": "^1.10.9",
8989
"qq": "^0.3.5",
9090
"rewire": "~2.1.0",
9191
"sax": "^1.1.1",
92-
"selenium-webdriver": "^2.53.1",
92+
"selenium-webdriver": "^4.0.0-alpha.1",
9393
"semver": "^5.4.1",
9494
"serve-favicon": "^2.3.0",
9595
"serve-index": "^1.8.0",

src/AngularPublic.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
htmlAnchorDirective,
99
inputDirective,
10-
inputDirective,
10+
hiddenInputBrowserCacheDirective,
1111
formDirective,
1212
scriptDirective,
1313
selectDirective,
@@ -221,7 +221,8 @@ function publishExternalAPI(angular) {
221221
ngModelOptions: ngModelOptionsDirective
222222
}).
223223
directive({
224-
ngInclude: ngIncludeFillContentDirective
224+
ngInclude: ngIncludeFillContentDirective,
225+
input: hiddenInputBrowserCacheDirective
225226
}).
226227
directive(ngAttributeAliasDirectives).
227228
directive(ngEventDirectives);

src/ng/directive/input.js

+42
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,48 @@ var inputDirective = ['$browser', '$sniffer', '$filter', '$parse',
21932193
}];
21942194

21952195

2196+
var hiddenInputBrowserCacheDirective = function() {
2197+
var valueProperty = {
2198+
configurable: true,
2199+
enumerable: false,
2200+
get: function() {
2201+
return this.getAttribute('value') || '';
2202+
},
2203+
set: function(val) {
2204+
this.setAttribute('value', val);
2205+
}
2206+
};
2207+
2208+
return {
2209+
restrict: 'E',
2210+
priority: 200,
2211+
compile: function(_, attr) {
2212+
if (lowercase(attr.type) !== 'hidden') {
2213+
return;
2214+
}
2215+
2216+
return {
2217+
pre: function(scope, element, attr, ctrls) {
2218+
var node = element[0];
2219+
2220+
// Support: Edge
2221+
// Moving the DOM around prevents autofillling
2222+
if (node.parentNode) {
2223+
node.parentNode.insertBefore(node, node.nextSibling);
2224+
}
2225+
2226+
// Support: FF, IE
2227+
// Avoiding direct assignment to .value prevents autofillling
2228+
if (Object.defineProperty) {
2229+
Object.defineProperty(node, 'value', valueProperty);
2230+
}
2231+
}
2232+
};
2233+
}
2234+
};
2235+
};
2236+
2237+
21962238

21972239
var CONSTANT_VALUE_REGEXP = /^(true|false|\d+)$/;
21982240
/**

test/e2e/fixtures/back2dom/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html ng-app="test">
3+
<body ng-class="{hacked: internalFnCalled}">
4+
<form>
5+
<input id="input1" type="hidden" value="{{value}}" />
6+
<input id="input2" type="hidden" ng-value="value" />
7+
8+
<textarea ng-model="value"></textarea>
9+
</form>
10+
<script src="angular.js"></script>
11+
<script src="script.js"></script>
12+
</body>
13+
</html>

test/e2e/fixtures/back2dom/script.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
angular
4+
.module('test', [])
5+
.run(function($rootScope) {
6+
$rootScope.internalFnCalled = false;
7+
8+
$rootScope.internalFn = function() {
9+
$rootScope.internalFnCalled = true;
10+
};
11+
});

test/e2e/tests/input-hidden.spec.js

+68
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,72 @@ describe('hidden thingy', function() {
1414
var expectedValue = browser.params.browser === 'safari' ? '{{ 7 * 6 }}' : '';
1515
expect(element(by.css('input')).getAttribute('value')).toEqual(expectedValue);
1616
});
17+
18+
it('should prevent browser autofill on browser.refresh', function() {
19+
20+
loadFixture('back2dom');
21+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('');
22+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('');
23+
24+
element(by.css('textarea')).sendKeys('{{ internalFn() }}');
25+
26+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('{{ internalFn() }}');
27+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('{{ internalFn() }}');
28+
expect(element(by.css('body')).getAttribute('class')).toBe('');
29+
30+
browser.refresh();
31+
expect(element(by.css('body')).getAttribute('class')).toBe('');
32+
});
33+
34+
it('should prevent browser autofill on location.reload', function() {
35+
36+
loadFixture('back2dom');
37+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('');
38+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('');
39+
40+
element(by.css('textarea')).sendKeys('{{ internalFn() }}');
41+
42+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('{{ internalFn() }}');
43+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('{{ internalFn() }}');
44+
expect(element(by.css('body')).getAttribute('class')).toBe('');
45+
46+
browser.driver.executeScript('location.reload()');
47+
expect(element(by.css('body')).getAttribute('class')).toBe('');
48+
});
49+
50+
it('should prevent browser autofill on history.back', function() {
51+
52+
loadFixture('back2dom');
53+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('');
54+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('');
55+
56+
element(by.css('textarea')).sendKeys('{{ internalFn() }}');
57+
58+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('{{ internalFn() }}');
59+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('{{ internalFn() }}');
60+
expect(element(by.css('body')).getAttribute('class')).toBe('');
61+
62+
loadFixture('sample');
63+
64+
browser.driver.executeScript('history.back()');
65+
expect(element(by.css('body')).getAttribute('class')).toBe('');
66+
});
67+
68+
it('should prevent browser autofill on history.forward', function() {
69+
70+
loadFixture('sample');
71+
loadFixture('back2dom');
72+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('');
73+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('');
74+
75+
element(by.css('textarea')).sendKeys('{{ internalFn() }}');
76+
77+
expect(element(by.css('#input1')).getAttribute('value')).toEqual('{{ internalFn() }}');
78+
expect(element(by.css('#input2')).getAttribute('value')).toEqual('{{ internalFn() }}');
79+
expect(element(by.css('body')).getAttribute('class')).toBe('');
80+
81+
browser.driver.executeScript('history.back()');
82+
browser.driver.executeScript('history.forward()');
83+
expect(element(by.css('body')).getAttribute('class')).toBe('');
84+
});
1785
});

0 commit comments

Comments
 (0)