$http
fails on LG webOS using the file://
protocol as cookies aren't accessible #15523
Description
Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.
Do you want to request a feature or report a bug?
bug
What is the current behavior?
On LG webOS using the file://
protocol, $http
fails because it calls $$cookieReader
that throws SecurityError: DOM Exception 18
.
$http
calls $$cookieReader
for CSRF checks: https://github.com/angular/angular.js/blob/v1.6.0/src/ng/http.js#L1287.
$$cookieReader
throws the error when accessing rawDocument.cookie
: https://github.com/angular/angular.js/blob/v1.6.0/src/ng/cookieReader.js#L27
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
Quite hard to reproduce, as you need an LG webOS device... Just make $$cookieReader
throw an error?
What is the expected behavior?
Either $http
or $$cookieReader
could catch errors so that xsrfValue
gets undefined if cookies aren't accessible?
What is the motivation / use case for changing the behavior?
To fix a bug :)
Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Issue met with 1.6.0 on LG webOS.
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Actual stack trace:
DOMException
code: 18
column: 42
constructor: DOMExceptionConstructor
line: 20114
message: "SecurityError: DOM Exception 18"
name: "SecurityError"
sourceURL: "file:///.../libs/angular/angular.js"
stack: "
file:///.../libs/angular/angular.js:20114:42
sendReq@file:///.../libs/angular/angular.js:12146:29
serverRequest@file:///.../libs/angular/angular.js:11905:23
processQueue@file:///.../libs/angular/angular.js:16643:39
file:///.../libs/angular/angular.js:16683:39
$eval@file:///.../libs/angular/angular.js:17958:28
$digest@file:///.../libs/angular/angular.js:17772:36
$apply@file:///.../libs/angular/angular.js:18066:31
bootstrapApply@file:///.../libs/angular/angular.js:1841:21
invoke@file:///.../libs/angular/angular.js:4839:24
doBootstrap@file:///.../libs/angular/angular.js:1839:20
bootstrap@file:///.../libs/angular/angular.js:1859:23
angularInit@file:///.../libs/angular/angular.js:1744:14
file:///.../libs/angular/angular.js:32890:16
mightThrow@file:///.../libs/jquery/dist/jquery.js:3570:34
file:///.../libs/jquery/dist/jquery.js:3638:22
"
__proto__: DOMExceptionPrototype
For now, I temporary decorate $$cookieReader
to disable it:
.config(["$provide",
function ($provide) {
$provide.decorator("$$cookieReader", [
function () {
return function () {
return {};
};
}]);
}])