* The IFrame transport * @param {FileItem} item * @private
(item)
| 537 | * @private |
| 538 | */ |
| 539 | _iframeTransport(item) { |
| 540 | var form = element('<form style="display: none;" />'); |
| 541 | var iframe = element('<iframe name="iframeTransport' + Date.now() + '">'); |
| 542 | var input = item._input; |
| 543 | |
| 544 | var timeout = 0; |
| 545 | var timer = null; |
| 546 | var isTimedOut = false; |
| 547 | |
| 548 | if(item._form) item._form.replaceWith(input); // remove old form |
| 549 | item._form = form; // save link to new form |
| 550 | |
| 551 | input.prop('name', item.alias); |
| 552 | |
| 553 | forEach(item.formData, (obj) => { |
| 554 | forEach(obj, (value, key) => { |
| 555 | var element_ = element('<input type="hidden" name="' + key + '" />'); |
| 556 | element_.val(value); |
| 557 | form.append(element_); |
| 558 | }); |
| 559 | }); |
| 560 | |
| 561 | form.prop({ |
| 562 | action: item.url, |
| 563 | method: 'POST', |
| 564 | target: iframe.prop('name'), |
| 565 | enctype: 'multipart/form-data', |
| 566 | encoding: 'multipart/form-data' // old IE |
| 567 | }); |
| 568 | |
| 569 | iframe.bind('load', () => { |
| 570 | var html = ''; |
| 571 | var status = 200; |
| 572 | |
| 573 | try { |
| 574 | // Fix for legacy IE browsers that loads internal error page |
| 575 | // when failed WS response received. In consequence iframe |
| 576 | // content access denied error is thrown becouse trying to |
| 577 | // access cross domain page. When such thing occurs notifying |
| 578 | // with empty response object. See more info at: |
| 579 | // http://stackoverflow.com/questions/151362/access-is-denied-error-on-accessing-iframe-document-object |
| 580 | // Note that if non standard 4xx or 5xx error code returned |
| 581 | // from WS then response content can be accessed without error |
| 582 | // but 'XHR' status becomes 200. In order to avoid confusion |
| 583 | // returning response via same 'success' event handler. |
| 584 | |
| 585 | // fixed angular.contents() for iframes |
| 586 | html = iframe[0].contentDocument.body.innerHTML; |
| 587 | } catch(e) { |
| 588 | // in case we run into the access-is-denied error or we have another error on the server side |
| 589 | // (intentional 500,40... errors), we at least say 'something went wrong' -> 500 |
| 590 | status = 500; |
| 591 | } |
| 592 | |
| 593 | if (timer) { |
| 594 | clearTimeout(timer); |
| 595 | } |
| 596 | timer = null; |
nothing calls this directly
no test coverage detected