|
47 | 47 | #include "builtins/transform-stream-default-controller.h"
|
48 | 48 | #include "builtins/transform-stream.h"
|
49 | 49 | #include "builtins/url.h"
|
| 50 | +#include "builtins/worker-location.h" |
50 | 51 |
|
51 | 52 | using JS::CallArgs;
|
52 | 53 | using JS::CallArgsFromVp;
|
@@ -3217,10 +3218,6 @@ CLASS_BOILERPLATE_NO_CTOR(ClientInfo)
|
3217 | 3218 | JSObject *create(JSContext *cx) { return JS_NewObjectWithGivenProto(cx, &class_, proto_obj); }
|
3218 | 3219 | } // namespace ClientInfo
|
3219 | 3220 |
|
3220 |
| -namespace WorkerLocation { |
3221 |
| -static PersistentRooted<JSObject *> url; |
3222 |
| -} |
3223 |
| - |
3224 | 3221 | namespace FetchEvent {
|
3225 | 3222 | namespace Slots {
|
3226 | 3223 | enum {
|
@@ -3626,81 +3623,6 @@ bool response_started(JSObject *self) {
|
3626 | 3623 | }
|
3627 | 3624 | } // namespace FetchEvent
|
3628 | 3625 |
|
3629 |
| -/** |
3630 |
| - * The `WorkerLocation` builtin, added to the global object as the data property |
3631 |
| - * `location`. |
3632 |
| - * https://html.spec.whatwg.org/multipage/workers.html#worker-locations |
3633 |
| - */ |
3634 |
| -namespace WorkerLocation { |
3635 |
| -namespace Slots { |
3636 |
| -enum { Count }; |
3637 |
| -}; |
3638 |
| - |
3639 |
| -const unsigned ctor_length = 1; |
3640 |
| - |
3641 |
| -bool constructor(JSContext *cx, unsigned argc, Value *vp) { |
3642 |
| - JS_ReportErrorLatin1(cx, "Illegal constructor WorkerLocation"); |
3643 |
| - return false; |
3644 |
| -} |
3645 |
| - |
3646 |
| -bool check_receiver(JSContext *cx, HandleValue receiver, const char *method_name); |
3647 |
| - |
3648 |
| -#define ACCESSOR_GET(field) \ |
3649 |
| - bool field##_get(JSContext *cx, unsigned argc, Value *vp) { \ |
3650 |
| - METHOD_HEADER(0) \ |
3651 |
| - REQUEST_HANDLER_ONLY("location." #field) \ |
3652 |
| - return URL::field(cx, url, args.rval()); \ |
3653 |
| - } |
3654 |
| - |
3655 |
| -ACCESSOR_GET(href) |
3656 |
| -ACCESSOR_GET(origin) |
3657 |
| -ACCESSOR_GET(protocol) |
3658 |
| -ACCESSOR_GET(host) |
3659 |
| -ACCESSOR_GET(hostname) |
3660 |
| -ACCESSOR_GET(port) |
3661 |
| -ACCESSOR_GET(pathname) |
3662 |
| -ACCESSOR_GET(search) |
3663 |
| -ACCESSOR_GET(hash) |
3664 |
| - |
3665 |
| -#undef ACCESSOR_GET |
3666 |
| - |
3667 |
| -bool toString(JSContext *cx, unsigned argc, Value *vp) { |
3668 |
| - METHOD_HEADER(0) |
3669 |
| - return href_get(cx, argc, vp); |
3670 |
| -} |
3671 |
| - |
3672 |
| -const JSFunctionSpec methods[] = {JS_FN("toString", toString, 0, JSPROP_ENUMERATE), JS_FS_END}; |
3673 |
| - |
3674 |
| -const JSPropertySpec properties[] = {JS_PSG("href", href_get, JSPROP_ENUMERATE), |
3675 |
| - JS_PSG("origin", origin_get, JSPROP_ENUMERATE), |
3676 |
| - JS_PSG("protocol", protocol_get, JSPROP_ENUMERATE), |
3677 |
| - JS_PSG("host", host_get, JSPROP_ENUMERATE), |
3678 |
| - JS_PSG("hostname", hostname_get, JSPROP_ENUMERATE), |
3679 |
| - JS_PSG("port", port_get, JSPROP_ENUMERATE), |
3680 |
| - JS_PSG("pathname", pathname_get, JSPROP_ENUMERATE), |
3681 |
| - JS_PSG("search", search_get, JSPROP_ENUMERATE), |
3682 |
| - JS_PSG("hash", hash_get, JSPROP_ENUMERATE), |
3683 |
| - JS_STRING_SYM_PS(toStringTag, "Location", JSPROP_READONLY), |
3684 |
| - JS_PS_END}; |
3685 |
| - |
3686 |
| -CLASS_BOILERPLATE_CUSTOM_INIT(WorkerLocation) |
3687 |
| - |
3688 |
| -bool init_class(JSContext *cx, HandleObject global) { |
3689 |
| - if (!init_class_impl(cx, global)) { |
3690 |
| - return false; |
3691 |
| - } |
3692 |
| - |
3693 |
| - url.init(cx); |
3694 |
| - |
3695 |
| - RootedObject location(cx, JS_NewObjectWithGivenProto(cx, &class_, proto_obj)); |
3696 |
| - if (!location) { |
3697 |
| - return false; |
3698 |
| - } |
3699 |
| - |
3700 |
| - return JS_DefineProperty(cx, global, "location", location, JSPROP_ENUMERATE); |
3701 |
| -} |
3702 |
| -} // namespace WorkerLocation |
3703 |
| - |
3704 | 3626 | namespace GlobalProperties {
|
3705 | 3627 | // TODO: throw in all Request methods/getters that rely on host calls once a
|
3706 | 3628 | // request has been sent. The host won't let us act on them anymore anyway.
|
|
0 commit comments