Repository: pyodide/pytest-pyodide (language: python)

Issue:
need to pass `AbortController` when making a VM context
Tests in CircleCI fail to import `AbortController` from `js`

> we need to pass AbortController when [making a VM context](https://github.com/pyodide/pytest-pyodide/blob/f957dcd510eb62af286df608ed9a1861adce1b6d/pytest_pyodide/node_test_driver.js#L18-L35).

_Originally posted by @ryanking13 in https://github.com/pyodide/pyodide/issues/4846#issuecomment-2158217070_
            


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index cfd710e..1696ebe 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -15,7 +15,7 @@ jobs:
       with:
         build-artifact-name: none
         build-artifact-path: none
-        pyodide-versions: "0.25.1,0.24.1,0.23.4"
+        pyodide-versions: "0.26.1,0.25.1,0.24.1"
 
   deploy:
     runs-on: ubuntu-20.04
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index fc3b6e1..d0745a6 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -41,52 +41,21 @@ permissions:
   contents: read
 
 jobs:
-  # separate job needed to setup the correct version of python and github os for pyodide version
-  get_versions:
-    runs-on: ubuntu-latest
-    name: Set python/os version (${{inputs.pyodide-version}},${{inputs.os}})
-    outputs:
-      os: ${{ steps.fix_runner_os.outputs.os }}
-      python: ${{ steps.get_python_version.outputs.python }}
-      pythonexec: ${{ steps.get_python_version.outputs.pythonexec }}
-    steps:
-      - name: Get python version for a particular pyodide version
-        id: get_python_version
-        run: |
-          case "${{inputs.pyodide-version}}" in
-            *)
-              echo "python=3.10.2" >> $GITHUB_OUTPUT
-              echo "pythonexec=python310" >> $GITHUB_OUTPUT
-              echo "Using python 3.10.2 for pyodide ${{inputs.pyodide-version}}"
-              ;;
-          esac
-      - name: Fix runner os
-        id: fix_runner_os
-        run: |
-          if [[ "${{ steps.get_python_version.outputs.python }}" == "3.10.2"  && "${{inputs.os}}" == ubuntu* && "${{inputs.os}}" != ubuntu-20.04 ]]
-          then
-            echo "Fixing ubuntu version ${{ inputs.os }} to ubuntu-20.04 for python 3.10.2"
-            echo "os=ubuntu-20.04" >> $GITHUB_OUTPUT
-          else
-            echo "Using existing OS: ${{inputs.os}} for python ${{ steps.get_python_version.outputs.python }}"
-            echo "os=${{inputs.os}}" >> $GITHUB_OUTPUT
-          fi
   test:
-    name: test ${{ inputs.browser }} ( ${{ inputs.runner }},${{ needs.get_versions.outputs.os }},pyodide:${{ inputs.pyodide-version}})
-    needs: get_versions
-    runs-on: ${{ needs.get_versions.outputs.os }}
+    name: test (${{ inputs.pyodide-version}},${{ inputs.browser }},${{ inputs.runner }})
+    runs-on: ${{ inputs.os }}
     env:
       DISPLAY: :99
     steps:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v3
         with:
-          python-version: ${{ needs.get_versions.outputs.python }}
+          python-version: 3.12
       - name: Install node
         uses: actions/setup-node@v3
         if: ${{ contains(inputs.browser, 'node') || inputs.runner == 'playwright' }}
         with:
-          node-version: ${{ inputs.node-version }}
+          node-version: ${{ inputs.browser-version }}
 
       - name: Cache Playwright browsers
         uses: actions/cache@v3
@@ -101,12 +70,12 @@ jobs:
         run: |
           if [ -n "${{ inputs.playwright-version }}" ]
           then
-            ${{needs.get_versions.outputs.pythonexec}} -m pip install playwright==${{inputs.playwright-version}}
+            python -m pip install playwright==${{inputs.playwright-version}}
           else
-            ${{needs.get_versions.outputs.pythonexec}} -m pip install playwright
+            python -m pip install playwright
           fi
           # TODO: install only browsers that are required
-          ${{needs.get_versions.outputs.pythonexec}} -m playwright install --with-deps
+          python -m playwright install --with-deps
 
       - uses: pyodide/pyodide-actions/download-pyodide@v1
         with:
@@ -118,7 +87,7 @@ jobs:
           runner: ${{ inputs.runner }}
           browser: ${{ inputs.browser }}
           browser-version: ${{ inputs.browser-version }}
-          playwright-version: ${{ inputs.runner-version }}
+          playwright-version: ${{ inputs.playwright-version }}
           github-token: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Download build artifacts from calling package
@@ -131,7 +100,7 @@ jobs:
       - name: install pyodide-py
         shell: bash -l {0}
         run: |
-          ${{needs.get_versions.outputs.pythonexec}} -m pip install pyodide-py==${{inputs.pyodide-version}}
+          python -m pip install pyodide-py==${{inputs.pyodide-version}}
 
 
       - name: Install pytest-pyodide
@@ -142,9 +111,9 @@ jobs:
             # We then uninstall it otherwise tests fails due to pytest hook being
             # registered twice.
             # temporarily pin pytest version (https://github.com/pyodide/pytest-pyodide/pull/133#issuecomment-2081412407)
-              ${{needs.get_versions.outputs.pythonexec}} -m pip install ".[test]" "pytest<8.0.0"
+              python -m pip install ".[test]" "pytest<8.0.0" "selenium<4.21.0"
           else
-              ${{needs.get_versions.outputs.pythonexec}} -m pip install pytest-pyodide
+              python -m pip install pytest-pyodide
           fi
       - name: Run tests
         shell: bash -l {0}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91dccd7..62f51f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## [0.58.0] - 2024-06-11
+
+- Expose  AbortController and AbortSignal to the node runner.
+  [#137](https://github.com/pyodide/pytest-pyodide/pull/137)
+
 ## [0.57.0] - 2024-04-30
 
 - Fixed safari compatibility with Selenium 4.20
diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md
index c28adc5..9b0a865 100644
--- a/COMPATIBILITY.md
+++ b/COMPATIBILITY.md
@@ -4,8 +4,9 @@ Following versions of pytest-pyodide and Pyodide are tested in CI.
 Other versions may work, however with no guarantee.
 
 | pytest-pyodide | Tested Pyodide versions |
-|----------------|-------------------------|
-| main branch    | 0.23.4, 0.24.1, 0.25.1  |
+| -------------- | ----------------------- |
+| main branch    | 0.24.1, 0.25.1, 0.26.1  |
+| 0.58.*         | 0.24.1, 0.25.1, 0.26.1  |
 | 0.57.*         | 0.23.4, 0.24.1, 0.25.1  |
 | 0.56.*         | 0.23.4, 0.24.1          |
 | 0.55.*         | 0.23.4, 0.24.1          |


Test patch:
diff --git a/.github/workflows/testall.yaml b/.github/workflows/testall.yaml
index aa80088..dd3f3e1 100644
--- a/.github/workflows/testall.yaml
+++ b/.github/workflows/testall.yaml
@@ -38,7 +38,7 @@ on:
         required: false
         type: string
         default: ""
-      playwright-version:
+      playwright-versions:
         required: false
         type: string
         default: ""  # latest
diff --git a/pytest_pyodide/node_test_driver.js b/pytest_pyodide/node_test_driver.js
index 812e50b..742ea08 100644
--- a/pytest_pyodide/node_test_driver.js
+++ b/pytest_pyodide/node_test_driver.js
@@ -29,7 +29,9 @@ const context = {
   clearTimeout,
   setInterval,
   setTimeout,
-  Headers
+  Headers,
+  AbortController,
+  AbortSignal,
 };
 vm.createContext(context);
 vm.runInContext("globalThis.self = globalThis;", context);
diff --git a/tests/test_decorator.py b/tests/test_decorator.py
index fddacd8..5b1ef20 100644
--- a/tests/test_decorator.py
+++ b/tests/test_decorator.py
@@ -282,8 +282,10 @@ def test_selenium_handle(selenium):
     assert_get_handle(selenium, handle, 7, 2)
     assert_get_handle(selenium, handle, "b", 1)
     check_refcount(selenium, 4)
+
+    # FIXME: refcount not decremented when deleting handle
     del handle
-    check_refcount(selenium, 3)
+    # check_refcount(selenium, 3)
 
 
 def test_pytest_dot_skip(selenium):
diff --git a/tests/test_js.py b/tests/test_js.py
new file mode 100644
index 0000000..2c355b9
--- /dev/null
+++ b/tests/test_js.py
@@ -0,0 +1,14 @@
+from pytest_pyodide import run_in_pyodide
+
+
+@run_in_pyodide()
+def test_js_globals(selenium_standalone):
+    import js
+
+    hasattr(js, "fetch")
+    hasattr(js, "Object")
+    hasattr(js, "AbortController")
+    hasattr(js, "AbortSignal")
+    hasattr(js, "setTimeout")
+    hasattr(js, "clearTimeout")
+    hasattr(js, "setInterval")
diff --git a/utils/build_test_matrix.py b/utils/build_test_matrix.py
index 184c28f..2a4a9b5 100644
--- a/utils/build_test_matrix.py
+++ b/utils/build_test_matrix.py
@@ -7,15 +7,13 @@
 import itertools
 import json
 
-DEFAULT_OS = "ubuntu-20.04, macos-11"
-DEFAULT_RUNNER = "selenium, playwright"
+DEFAULT_OS = "ubuntu-latest, macos-latest"
+DEFAULT_RUNNER = "selenium"
 DEFAULT_BROWSER = "chrome, firefox, node, safari, host"
 DEFAULT_CHROME_VERSION = "latest"
 DEFAULT_FIREFOX_VERSION = "latest"
-DEFAULT_NODE_VERSION = "20"
-DEFAULT_PLAYWRIGHT_VERSION = (
-    "1.22.0"  # TODO: versions > 1.22.0 have firefox performance issue
-)
+DEFAULT_NODE_VERSION = "22"
+DEFAULT_PLAYWRIGHT_VERSION = "1.44.0"
 
 
 @dataclasses.dataclass