content/dom: set navigator.onLine attribute to true (#36560)

Sets the navigator.onLine attribute to true.

Testing:
Ran `./mach run https://pinterest.com
--enable-experimental-web-platform-features`. This doesn't show the
"Hmm..you're not connected to the internet" text anymore.
<img width="1027" alt="Screenshot 2025-04-16 at 11 31 02 AM"
src="https://github.com/user-attachments/assets/3745077b-dc51-42ce-88a0-38d5f157fc0c"
/>


part of: #36554

---------

Signed-off-by: Siddhant N. Trivedi <sidntrivedi012@gmail.com>
Signed-off-by: Siddhant N Trivedi <sidntrivedi012@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Siddhant N Trivedi 2025-04-19 07:04:13 +05:30 committed by GitHub
parent c787688afc
commit 7ee9d07a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 18 additions and 24 deletions

View file

@ -222,6 +222,11 @@ impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
to_frozen_array(&[self.Language()], cx, retval, can_gc) to_frozen_array(&[self.Language()], cx, retval, can_gc)
} }
/// <https://html.spec.whatwg.org/multipage/#dom-navigator-online>
fn OnLine(&self) -> bool {
true
}
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins // https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
fn Plugins(&self) -> DomRoot<PluginArray> { fn Plugins(&self) -> DomRoot<PluginArray> {
self.plugins self.plugins

View file

@ -105,6 +105,11 @@ impl WorkerNavigatorMethods<crate::DomTypeHolder> for WorkerNavigator {
to_frozen_array(&[self.Language()], cx, retval, can_gc) to_frozen_array(&[self.Language()], cx, retval, can_gc)
} }
/// <https://html.spec.whatwg.org/multipage/#dom-navigator-online>
fn OnLine(&self) -> bool {
true
}
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension // https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
fn Permissions(&self) -> DomRoot<Permissions> { fn Permissions(&self) -> DomRoot<Permissions> {
self.permissions self.permissions

View file

@ -9,7 +9,7 @@ interface Navigator {
}; };
Navigator includes NavigatorID; Navigator includes NavigatorID;
Navigator includes NavigatorLanguage; Navigator includes NavigatorLanguage;
//Navigator includes NavigatorOnLine; Navigator includes NavigatorOnLine;
//Navigator includes NavigatorContentUtils; //Navigator includes NavigatorContentUtils;
//Navigator includes NavigatorStorageUtils; //Navigator includes NavigatorStorageUtils;
Navigator includes NavigatorPlugins; Navigator includes NavigatorPlugins;
@ -43,6 +43,12 @@ interface mixin NavigatorLanguage {
readonly attribute any languages; readonly attribute any languages;
}; };
// https://html.spec.whatwg.org/multipage/#dom-navigator-online
[Exposed=(Window,Worker)]
interface mixin NavigatorOnLine {
readonly attribute boolean onLine;
};
// https://html.spec.whatwg.org/multipage/#navigatorplugins // https://html.spec.whatwg.org/multipage/#navigatorplugins
interface mixin NavigatorPlugins { interface mixin NavigatorPlugins {
[SameObject] readonly attribute PluginArray plugins; [SameObject] readonly attribute PluginArray plugins;

View file

@ -7,7 +7,7 @@
interface WorkerNavigator {}; interface WorkerNavigator {};
WorkerNavigator includes NavigatorID; WorkerNavigator includes NavigatorID;
WorkerNavigator includes NavigatorLanguage; WorkerNavigator includes NavigatorLanguage;
//WorkerNavigator includes NavigatorOnLine; WorkerNavigator includes NavigatorOnLine;
WorkerNavigator includes NavigatorConcurrentHardware; WorkerNavigator includes NavigatorConcurrentHardware;
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension // https://w3c.github.io/permissions/#navigator-and-workernavigator-extension

View file

@ -1,3 +0,0 @@
[navigator_online_online.https.html]
[Offline Application Cache - navigator_online_online]
expected: FAIL

View file

@ -185,15 +185,9 @@
[WorkerNavigator interface: member taintEnabled] [WorkerNavigator interface: member taintEnabled]
expected: FAIL expected: FAIL
[WorkerNavigator interface: attribute onLine]
expected: FAIL
[WorkerNavigator interface: self.navigator must not have property "taintEnabled"] [WorkerNavigator interface: self.navigator must not have property "taintEnabled"]
expected: FAIL expected: FAIL
[WorkerNavigator interface: self.navigator must inherit property "onLine" with the proper type]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation getContextAttributes()] [OffscreenCanvasRenderingContext2D interface: operation getContextAttributes()]
expected: FAIL expected: FAIL

View file

@ -695,9 +695,6 @@
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "imageSmoothingQuality" with the proper type] [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "imageSmoothingQuality" with the proper type]
expected: FAIL expected: FAIL
[Navigator interface: attribute onLine]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation getLineDash()] [OffscreenCanvasRenderingContext2D interface: operation getLineDash()]
expected: FAIL expected: FAIL
@ -5348,9 +5345,6 @@
[Navigator interface: attribute oscpu] [Navigator interface: attribute oscpu]
expected: FAIL expected: FAIL
[Navigator interface: attribute onLine]
expected: FAIL
[Navigator interface: operation registerProtocolHandler(DOMString, USVString)] [Navigator interface: operation registerProtocolHandler(DOMString, USVString)]
expected: FAIL expected: FAIL
@ -5366,9 +5360,6 @@
[Navigator interface: window.navigator must inherit property "oscpu" with the proper type] [Navigator interface: window.navigator must inherit property "oscpu" with the proper type]
expected: FAIL expected: FAIL
[Navigator interface: window.navigator must inherit property "onLine" with the proper type]
expected: FAIL
[Navigator interface: window.navigator must inherit property "registerProtocolHandler(DOMString, USVString)" with the proper type] [Navigator interface: window.navigator must inherit property "registerProtocolHandler(DOMString, USVString)" with the proper type]
expected: FAIL expected: FAIL

View file

@ -3,7 +3,3 @@
[WorkerNavigator.any.serviceworker.html] [WorkerNavigator.any.serviceworker.html]
expected: ERROR expected: ERROR
[WorkerNavigator.any.worker.html]
[Testing Navigator properties on workers.]
expected: FAIL