(win, input, opt_init)
| 20 | * @ignore |
| 21 | */ |
| 22 | export function fetchDocument(win, input, opt_init) { |
| 23 | let init = setupInit(opt_init, 'text/html'); |
| 24 | init = setupAMPCors(win, input, init); |
| 25 | input = setupInput(win, input, init); |
| 26 | const ampdocService = Services.ampdocServiceFor(win); |
| 27 | const ampdocSingle = ampdocService.isSingleDoc() |
| 28 | ? ampdocService.getSingleDoc() |
| 29 | : null; |
| 30 | init.responseType = 'document'; |
| 31 | return getViewerInterceptResponse(win, ampdocSingle, input, init).then( |
| 32 | (interceptorResponse) => { |
| 33 | if (interceptorResponse) { |
| 34 | return interceptorResponse |
| 35 | .text() |
| 36 | .then((body) => new DOMParser().parseFromString(body, 'text/html')); |
| 37 | } |
| 38 | return xhrRequest(input, init).then((resp) => { |
| 39 | const {xhr} = resp; |
| 40 | return xhr.responseXML; |
| 41 | }); |
| 42 | } |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * |
no test coverage detected