| Line 271... |
Line 271... |
| 271 |
private void installResponseCapture(WebDriver driver) {
|
271 |
private void installResponseCapture(WebDriver driver) {
|
| 272 |
try {
|
272 |
try {
|
| 273 |
((JavascriptExecutor) driver).executeScript(
|
273 |
((JavascriptExecutor) driver).executeScript(
|
| 274 |
"if (!window.__rmCapInstalled) {"
|
274 |
"if (!window.__rmCapInstalled) {"
|
| 275 |
+ " window.__rmCapInstalled = true; window.__rmResp = null;"
|
275 |
+ " window.__rmCapInstalled = true; window.__rmResp = null;"
|
| - |
|
276 |
// axios can sit on either transport, and realme's page uses fetch --
|
| - |
|
277 |
// an XHR-only hook silently captures nothing, which is exactly what
|
| - |
|
278 |
// 'no active/check response captured' was reporting.
|
| 276 |
+ " var O = XMLHttpRequest.prototype.open;"
|
279 |
+ " var O = XMLHttpRequest.prototype.open;"
|
| 277 |
+ " XMLHttpRequest.prototype.open = function(m,u){"
|
280 |
+ " XMLHttpRequest.prototype.open = function(m,u){"
|
| 278 |
+ " this.addEventListener('load', function(){"
|
281 |
+ " this.addEventListener('load', function(){"
|
| 279 |
+ " try { if (String(u).indexOf('active/check') !== -1) window.__rmResp = this.responseText; } catch(e){}"
|
282 |
+ " try { if (String(u).indexOf('active/check') !== -1) window.__rmResp = this.responseText; } catch(e){}"
|
| 280 |
+ " });"
|
283 |
+ " });"
|
| 281 |
+ " return O.apply(this, arguments);"
|
284 |
+ " return O.apply(this, arguments);"
|
| 282 |
+ " };"
|
285 |
+ " };"
|
| - |
|
286 |
+ " var F = window.fetch;"
|
| - |
|
287 |
+ " if (F) { window.fetch = function(){"
|
| - |
|
288 |
+ " var u = arguments[0]; u = (u && u.url) ? u.url : String(u);"
|
| - |
|
289 |
+ " return F.apply(this, arguments).then(function(r){"
|
| - |
|
290 |
+ " try { if (u.indexOf('active/check') !== -1) { r.clone().text().then(function(t){ window.__rmResp = t; }); } } catch(e){}"
|
| - |
|
291 |
+ " return r;"
|
| - |
|
292 |
+ " });"
|
| - |
|
293 |
+ " }; }"
|
| 283 |
+ "}");
|
294 |
+ "}");
|
| 284 |
} catch (Exception e) {
|
295 |
} catch (Exception e) {
|
| 285 |
LOGGER.warn("Could not install the response capture hook: " + e.getMessage());
|
296 |
LOGGER.warn("Could not install the response capture hook: " + e.getMessage());
|
| 286 |
}
|
297 |
}
|
| 287 |
}
|
298 |
}
|