Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 function initialize_DocumentationTests() | |
| 2 { | |
| 3 | |
| 4 InspectorTest.mockLoadXHR = function(urlPrefix, responseText) | |
| 5 { | |
| 6 window.loadXHR = function(url) | |
| 7 { | |
| 8 return new Promise(load); | |
|
lushnikov
2014/09/12 10:47:20
you want to discretely fall-back to the original l
| |
| 9 | |
| 10 function load(successCallback, failureCallback) | |
| 11 { | |
| 12 function onReadyStateChanged() | |
| 13 { | |
| 14 if (xhr.readyState !== XMLHttpRequest.DONE) | |
| 15 return; | |
| 16 if (xhr.status !== 200) { | |
| 17 xhr.onreadystatechange = null; | |
| 18 failureCallback(new Error(xhr.status)); | |
| 19 return; | |
| 20 } | |
| 21 xhr.onreadystatechange = null; | |
| 22 successCallback(xhr.responseText); | |
| 23 } | |
| 24 | |
| 25 if (url.startsWith(urlPrefix)) { | |
| 26 successCallback(responseText); | |
| 27 return; | |
| 28 } | |
| 29 | |
| 30 var xhr = new XMLHttpRequest(); | |
| 31 xhr.open("GET", url, true); | |
| 32 xhr.onreadystatechange = onReadyStateChanged; | |
| 33 xhr.send(null); | |
| 34 } | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 } | |
| OLD | NEW |