限制

浏览器限制

¥Browser limitations

此库使用 Service Worker API 拦截浏览器中的请求。浏览器在实现或执行上述 API 时可能遇到的任何限制都会自动成为 Mock Service Worker 库的限制。我们无法解决此行为,因为它们存在于浏览器中,并且无法通过 JavaScript 规避。

¥This library uses the Service Worker API to intercept requests in the browser. Any limitations that browsers may have when implementing or executing the said API automatically become the limitations of the Mock Service Worker library. We cannot address this behaviors as they are present in the browser and cannot be circumvented by JavaScript.

Firefox 在 XMLHttpRequest 上未发出 “fetch” 事件

¥Firefox does not emit “fetch” event on XMLHttpRequest

当页面上发生 XMLHttpRequest 时,Firefox 不会通知工作程序。这意味着工作者以及因此而产生的这个库不知道何时发生此类请求。即使你有一个匹配的请求处理程序,如果它是 XMLHttpRequest,它也不会被匹配,并且模拟响应不会被发送。

¥Firefox does not notify the worker when an XMLHttpRequest happens on the page. This means that the worker and, as the result, this library, do not know when such requests occur. Even if you have a matching request handler for the request, it won’t be matched and the mocked response won’t be sent if it’s an XMLHttpRequest.

Mock Service Worker 将自己定位为开发工具,这意味着我们无法保证与所有现代浏览器 100% 兼容。最后,每个浏览器在 Service Worker API 的实现方式上可能存在差异,我们也无法解释。

¥Mock Service Worker positions itself as a development tool, which means we cannot guarantee 100% compatibility with all modern browsers. In the end, each browser may have its discrepancies in how the Service Worker API is implemented, for which we also cannot account for.