We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Gtk] WebView uses deprecated run_javascript api
### Describe the bug

The Gtk backend for `toga.WebView` uses the `run_javascript()` API to evaluate JavaScript. This was deprecated in WebView v2.40 in favour of `evaluate_javascript()`. Since we depend on WebKit v4.0 or later, we should switch to the non-deprecated API. See https://webkitgtk.org/reference/webkit2gtk/stable/method.WebView.run_javascript.html.

### Steps to reproduce

Evaluate some JavaScript using `toga.WebView` on Linux with the Gtk backend. See the followig deprecation warning:

```
/home/parallels/maestral/lib/python3.10/site-packages/toga_gtk/widgets/webview.py:106: DeprecationWarning: WebKit2.WebView.run_javascript is deprecated
  self.native.run_javascript(javascript, None, gtk_js_finished)
/home/parallels/maestral/lib/python3.10/site-packages/toga_gtk/widgets/webview.py:86: DeprecationWarning: WebKit2.WebView.run_javascript_finish is deprecated
  js_result = webview.run_javascript_finish(task)
```

### Expected behavior

Don't use deprecated APIs unless required for backward compatibility.

### Screenshots

_No response_

### Environment

- Operating System: Ubuntu 22.04
- Python version: Python 3.10
- Software versions:
  - Toga: 0.3.2.dev804+g609682318


### Logs

_No response_

### Additional context

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gtk/src/toga_gtk/widgets/webview.py`
Content:
```
1 from travertino.size import at_least
2 
3 from toga.widgets.webview import JavaScriptResult
4 
5 from ..libs import GLib, WebKit2
6 from .base import Widget
7 
8 
9 class WebView(Widget):
10     """GTK WebView implementation."""
11 
12     def create(self):
13         if WebKit2 is None:  # pragma: no cover
14             raise RuntimeError(
15                 "Unable to import WebKit2. Ensure that the system package "
16                 "providing Webkit2 and its GTK bindings have been installed."
17             )
18 
19         self.native = WebKit2.WebView()
20 
21         settings = self.native.get_settings()
22         settings.set_property("enable-developer-extras", True)
23 
24         # The default cache model is WEB_BROWSER, which will
25         # use the backing cache to minimize hits on the web server.
26         # This can result in stale web content being served, even if
27         # the source document (and the web server response) changes.
28         context = self.native.get_context()
29         context.set_cache_model(WebKit2.CacheModel.DOCUMENT_VIEWER)
30 
31         self.native.connect("load-changed", self.gtk_on_load_changed)
32 
33         self.load_future = None
34 
35     def gtk_on_load_changed(self, widget, load_event, *args):
36         if load_event == WebKit2.LoadEvent.FINISHED:
37             self.interface.on_webview_load(None)
38 
39             if self.load_future:
40                 self.load_future.set_result(None)
41                 self.load_future = None
42 
43     def get_url(self):
44         url = self.native.get_uri()
45         return None if url == "about:blank" else url
46 
47     def _loaded(self, data):
48         # Internal method to fake a load event.
49         self.native.emit("load-changed", WebKit2.LoadEvent.FINISHED)
50         return False
51 
52     def set_url(self, value, future=None):
53         if value:
54             self.native.load_uri(value)
55         else:
56             self.native.load_plain_text("")
57             # GTK doesn't emit a load-changed signal when plain text is loaded; so we
58             # fake it. We can't emit the signal directly because it will be handled
59             # immediately. During creation of an empty webview, the URL is set to None,
60             # which means an event can be triggered before the widget instance has
61             # finished construction. So, we defer the call with a 0 timeout.
62             GLib.timeout_add(0, self._loaded, None)
63 
64         self.load_future = future
65 
66     def get_user_agent(self):
67         return self.native.get_settings().props.user_agent
68 
69     def set_user_agent(self, value):
70         # replace user agent of webview (webview has own one)
71         self.native.get_settings().props.user_agent = value
72 
73     def set_content(self, root_url, content):
74         self.native.load_html(content, root_url)
75 
76     def evaluate_javascript(self, javascript, on_result=None):
77         # Construct a future on the event loop
78         result = JavaScriptResult()
79 
80         # Define a callback that will update the future when
81         # the Javascript is complete.
82         def gtk_js_finished(webview, task, *user_data):
83             """If `run_javascript_finish` from GTK returns a result, unmarshal it, and
84             call back with the result."""
85             try:
86                 js_result = webview.run_javascript_finish(task)
87                 value = js_result.get_js_value()
88                 if value.is_boolean():
89                     value = value.to_boolean()
90                 elif value.is_number():
91                     value = value.to_double()
92                 else:
93                     value = value.to_string()
94 
95                 result.future.set_result(value)
96                 if on_result:
97                     on_result(value)
98             except Exception as e:
99                 exc = RuntimeError(str(e))
100                 result.future.set_exception(exc)
101                 if on_result:
102                     on_result(None, exception=exc)
103 
104         # Invoke the javascript method, with a callback that will set
105         # the future when a result is available.
106         self.native.run_javascript(javascript, None, gtk_js_finished)
107 
108         # wait for the future, and return the result
109         return result
110 
111     def rehint(self):
112         self.interface.intrinsic.width = at_least(self.interface._MIN_WIDTH)
113         self.interface.intrinsic.height = at_least(self.interface._MIN_HEIGHT)
114
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gtk/src/toga_gtk/widgets/webview.py b/gtk/src/toga_gtk/widgets/webview.py
--- a/gtk/src/toga_gtk/widgets/webview.py
+++ b/gtk/src/toga_gtk/widgets/webview.py
@@ -80,11 +80,10 @@
         # Define a callback that will update the future when
         # the Javascript is complete.
         def gtk_js_finished(webview, task, *user_data):
-            """If `run_javascript_finish` from GTK returns a result, unmarshal it, and
+            """If `evaluate_javascript_finish` from GTK returns a result, unmarshal it, and
             call back with the result."""
             try:
-                js_result = webview.run_javascript_finish(task)
-                value = js_result.get_js_value()
+                value = webview.evaluate_javascript_finish(task)
                 if value.is_boolean():
                     value = value.to_boolean()
                 elif value.is_number():
@@ -103,7 +102,14 @@
 
         # Invoke the javascript method, with a callback that will set
         # the future when a result is available.
-        self.native.run_javascript(javascript, None, gtk_js_finished)
+        self.native.evaluate_javascript(
+            script=javascript,
+            length=len(javascript),
+            world_name=None,
+            source_uri=None,
+            cancellable=None,
+            callback=gtk_js_finished,
+        )
 
         # wait for the future, and return the result
         return result

{"golden_diff": "diff --git a/gtk/src/toga_gtk/widgets/webview.py b/gtk/src/toga_gtk/widgets/webview.py\n--- a/gtk/src/toga_gtk/widgets/webview.py\n+++ b/gtk/src/toga_gtk/widgets/webview.py\n@@ -80,11 +80,10 @@\n         # Define a callback that will update the future when\n         # the Javascript is complete.\n         def gtk_js_finished(webview, task, *user_data):\n-            \"\"\"If `run_javascript_finish` from GTK returns a result, unmarshal it, and\n+            \"\"\"If `evaluate_javascript_finish` from GTK returns a result, unmarshal it, and\n             call back with the result.\"\"\"\n             try:\n-                js_result = webview.run_javascript_finish(task)\n-                value = js_result.get_js_value()\n+                value = webview.evaluate_javascript_finish(task)\n                 if value.is_boolean():\n                     value = value.to_boolean()\n                 elif value.is_number():\n@@ -103,7 +102,14 @@\n \n         # Invoke the javascript method, with a callback that will set\n         # the future when a result is available.\n-        self.native.run_javascript(javascript, None, gtk_js_finished)\n+        self.native.evaluate_javascript(\n+            script=javascript,\n+            length=len(javascript),\n+            world_name=None,\n+            source_uri=None,\n+            cancellable=None,\n+            callback=gtk_js_finished,\n+        )\n \n         # wait for the future, and return the result\n         return result\n", "issue": "[Gtk] WebView uses deprecated run_javascript api\n### Describe the bug\r\n\r\nThe Gtk backend for `toga.WebView` uses the `run_javascript()` API to evaluate JavaScript. This was deprecated in WebView v2.40 in favour of `evaluate_javascript()`. Since we depend on WebKit v4.0 or later, we should switch to the non-deprecated API. See https://webkitgtk.org/reference/webkit2gtk/stable/method.WebView.run_javascript.html.\r\n\r\n### Steps to reproduce\r\n\r\nEvaluate some JavaScript using `toga.WebView` on Linux with the Gtk backend. See the followig deprecation warning:\r\n\r\n```\r\n/home/parallels/maestral/lib/python3.10/site-packages/toga_gtk/widgets/webview.py:106: DeprecationWarning: WebKit2.WebView.run_javascript is deprecated\r\n  self.native.run_javascript(javascript, None, gtk_js_finished)\r\n/home/parallels/maestral/lib/python3.10/site-packages/toga_gtk/widgets/webview.py:86: DeprecationWarning: WebKit2.WebView.run_javascript_finish is deprecated\r\n  js_result = webview.run_javascript_finish(task)\r\n```\r\n\r\n### Expected behavior\r\n\r\nDon't use deprecated APIs unless required for backward compatibility.\r\n\r\n### Screenshots\r\n\r\n_No response_\r\n\r\n### Environment\r\n\r\n- Operating System: Ubuntu 22.04\r\n- Python version: Python 3.10\r\n- Software versions:\r\n  - Toga: 0.3.2.dev804+g609682318\r\n\r\n\r\n### Logs\r\n\r\n_No response_\r\n\r\n### Additional context\r\n\r\n_No response_\n", "before_files": [{"content": "from travertino.size import at_least\n\nfrom toga.widgets.webview import JavaScriptResult\n\nfrom ..libs import GLib, WebKit2\nfrom .base import Widget\n\n\nclass WebView(Widget):\n    \"\"\"GTK WebView implementation.\"\"\"\n\n    def create(self):\n        if WebKit2 is None:  # pragma: no cover\n            raise RuntimeError(\n                \"Unable to import WebKit2. Ensure that the system package \"\n                \"providing Webkit2 and its GTK bindings have been installed.\"\n            )\n\n        self.native = WebKit2.WebView()\n\n        settings = self.native.get_settings()\n        settings.set_property(\"enable-developer-extras\", True)\n\n        # The default cache model is WEB_BROWSER, which will\n        # use the backing cache to minimize hits on the web server.\n        # This can result in stale web content being served, even if\n        # the source document (and the web server response) changes.\n        context = self.native.get_context()\n        context.set_cache_model(WebKit2.CacheModel.DOCUMENT_VIEWER)\n\n        self.native.connect(\"load-changed\", self.gtk_on_load_changed)\n\n        self.load_future = None\n\n    def gtk_on_load_changed(self, widget, load_event, *args):\n        if load_event == WebKit2.LoadEvent.FINISHED:\n            self.interface.on_webview_load(None)\n\n            if self.load_future:\n                self.load_future.set_result(None)\n                self.load_future = None\n\n    def get_url(self):\n        url = self.native.get_uri()\n        return None if url == \"about:blank\" else url\n\n    def _loaded(self, data):\n        # Internal method to fake a load event.\n        self.native.emit(\"load-changed\", WebKit2.LoadEvent.FINISHED)\n        return False\n\n    def set_url(self, value, future=None):\n        if value:\n            self.native.load_uri(value)\n        else:\n            self.native.load_plain_text(\"\")\n            # GTK doesn't emit a load-changed signal when plain text is loaded; so we\n            # fake it. We can't emit the signal directly because it will be handled\n            # immediately. During creation of an empty webview, the URL is set to None,\n            # which means an event can be triggered before the widget instance has\n            # finished construction. So, we defer the call with a 0 timeout.\n            GLib.timeout_add(0, self._loaded, None)\n\n        self.load_future = future\n\n    def get_user_agent(self):\n        return self.native.get_settings().props.user_agent\n\n    def set_user_agent(self, value):\n        # replace user agent of webview (webview has own one)\n        self.native.get_settings().props.user_agent = value\n\n    def set_content(self, root_url, content):\n        self.native.load_html(content, root_url)\n\n    def evaluate_javascript(self, javascript, on_result=None):\n        # Construct a future on the event loop\n        result = JavaScriptResult()\n\n        # Define a callback that will update the future when\n        # the Javascript is complete.\n        def gtk_js_finished(webview, task, *user_data):\n            \"\"\"If `run_javascript_finish` from GTK returns a result, unmarshal it, and\n            call back with the result.\"\"\"\n            try:\n                js_result = webview.run_javascript_finish(task)\n                value = js_result.get_js_value()\n                if value.is_boolean():\n                    value = value.to_boolean()\n                elif value.is_number():\n                    value = value.to_double()\n                else:\n                    value = value.to_string()\n\n                result.future.set_result(value)\n                if on_result:\n                    on_result(value)\n            except Exception as e:\n                exc = RuntimeError(str(e))\n                result.future.set_exception(exc)\n                if on_result:\n                    on_result(None, exception=exc)\n\n        # Invoke the javascript method, with a callback that will set\n        # the future when a result is available.\n        self.native.run_javascript(javascript, None, gtk_js_finished)\n\n        # wait for the future, and return the result\n        return result\n\n    def rehint(self):\n        self.interface.intrinsic.width = at_least(self.interface._MIN_WIDTH)\n        self.interface.intrinsic.height = at_least(self.interface._MIN_HEIGHT)\n", "path": "gtk/src/toga_gtk/widgets/webview.py"}], "after_files": [{"content": "from travertino.size import at_least\n\nfrom toga.widgets.webview import JavaScriptResult\n\nfrom ..libs import GLib, WebKit2\nfrom .base import Widget\n\n\nclass WebView(Widget):\n    \"\"\"GTK WebView implementation.\"\"\"\n\n    def create(self):\n        if WebKit2 is None:  # pragma: no cover\n            raise RuntimeError(\n                \"Unable to import WebKit2. Ensure that the system package \"\n                \"providing Webkit2 and its GTK bindings have been installed.\"\n            )\n\n        self.native = WebKit2.WebView()\n\n        settings = self.native.get_settings()\n        settings.set_property(\"enable-developer-extras\", True)\n\n        # The default cache model is WEB_BROWSER, which will\n        # use the backing cache to minimize hits on the web server.\n        # This can result in stale web content being served, even if\n        # the source document (and the web server response) changes.\n        context = self.native.get_context()\n        context.set_cache_model(WebKit2.CacheModel.DOCUMENT_VIEWER)\n\n        self.native.connect(\"load-changed\", self.gtk_on_load_changed)\n\n        self.load_future = None\n\n    def gtk_on_load_changed(self, widget, load_event, *args):\n        if load_event == WebKit2.LoadEvent.FINISHED:\n            self.interface.on_webview_load(None)\n\n            if self.load_future:\n                self.load_future.set_result(None)\n                self.load_future = None\n\n    def get_url(self):\n        url = self.native.get_uri()\n        return None if url == \"about:blank\" else url\n\n    def _loaded(self, data):\n        # Internal method to fake a load event.\n        self.native.emit(\"load-changed\", WebKit2.LoadEvent.FINISHED)\n        return False\n\n    def set_url(self, value, future=None):\n        if value:\n            self.native.load_uri(value)\n        else:\n            self.native.load_plain_text(\"\")\n            # GTK doesn't emit a load-changed signal when plain text is loaded; so we\n            # fake it. We can't emit the signal directly because it will be handled\n            # immediately. During creation of an empty webview, the URL is set to None,\n            # which means an event can be triggered before the widget instance has\n            # finished construction. So, we defer the call with a 0 timeout.\n            GLib.timeout_add(0, self._loaded, None)\n\n        self.load_future = future\n\n    def get_user_agent(self):\n        return self.native.get_settings().props.user_agent\n\n    def set_user_agent(self, value):\n        # replace user agent of webview (webview has own one)\n        self.native.get_settings().props.user_agent = value\n\n    def set_content(self, root_url, content):\n        self.native.load_html(content, root_url)\n\n    def evaluate_javascript(self, javascript, on_result=None):\n        # Construct a future on the event loop\n        result = JavaScriptResult()\n\n        # Define a callback that will update the future when\n        # the Javascript is complete.\n        def gtk_js_finished(webview, task, *user_data):\n            \"\"\"If `evaluate_javascript_finish` from GTK returns a result, unmarshal it, and\n            call back with the result.\"\"\"\n            try:\n                value = webview.evaluate_javascript_finish(task)\n                if value.is_boolean():\n                    value = value.to_boolean()\n                elif value.is_number():\n                    value = value.to_double()\n                else:\n                    value = value.to_string()\n\n                result.future.set_result(value)\n                if on_result:\n                    on_result(value)\n            except Exception as e:\n                exc = RuntimeError(str(e))\n                result.future.set_exception(exc)\n                if on_result:\n                    on_result(None, exception=exc)\n\n        # Invoke the javascript method, with a callback that will set\n        # the future when a result is available.\n        self.native.evaluate_javascript(\n            script=javascript,\n            length=len(javascript),\n            world_name=None,\n            source_uri=None,\n            cancellable=None,\n            callback=gtk_js_finished,\n        )\n\n        # wait for the future, and return the result\n        return result\n\n    def rehint(self):\n        self.interface.intrinsic.width = at_least(self.interface._MIN_WIDTH)\n        self.interface.intrinsic.height = at_least(self.interface._MIN_HEIGHT)\n", "path": "gtk/src/toga_gtk/widgets/webview.py"}]}