Ver código fonte

LibWeb: Add ServiceWorker discarded flag to ESO

Looking at the spec it doesn't seem like there's a chance for a service
worker client to be an environment but not an environment settings
object. In the case that that changes in the implementation, we can
move it.
Andrew Kaster 11 meses atrás
pai
commit
237bcbff36

+ 7 - 0
Userland/Libraries/LibWeb/HTML/Scripting/Environments.h

@@ -124,6 +124,9 @@ public:
 
 
     JS::NonnullGCPtr<StorageAPI::StorageManager> storage_manager();
     JS::NonnullGCPtr<StorageAPI::StorageManager> storage_manager();
 
 
+    [[nodiscard]] bool discarded() const { return m_discarded; }
+    void set_discarded(bool b) { m_discarded = b; }
+
 protected:
 protected:
     explicit EnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext>);
     explicit EnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext>);
 
 
@@ -149,6 +152,10 @@ private:
     // https://storage.spec.whatwg.org/#api
     // https://storage.spec.whatwg.org/#api
     // Each environment settings object has an associated StorageManager object.
     // Each environment settings object has an associated StorageManager object.
     JS::GCPtr<StorageAPI::StorageManager> m_storage_manager;
     JS::GCPtr<StorageAPI::StorageManager> m_storage_manager;
+
+    // https://w3c.github.io/ServiceWorker/#service-worker-client-discarded-flag
+    // A service worker client has an associated discarded flag. It is initially unset.
+    bool m_discarded { false };
 };
 };
 
 
 EnvironmentSettingsObject& incumbent_settings_object();
 EnvironmentSettingsObject& incumbent_settings_object();