Further refine the regex used to find STP releases
This also substantially increases the number of tests we have for
this; these are based on a subset of the download pages fetched from
the Wayback Machine, manually filtered to those which are perhaps more
'interesting'.
diff --git a/tools/wpt/browser.py b/tools/wpt/browser.py
index cf8336b..cc3e793 100644
--- a/tools/wpt/browser.py
+++ b/tools/wpt/browser.py
@@ -6,7 +6,6 @@
import stat
import subprocess
import tempfile
-import xml.etree.ElementTree as etree # noqa: N813
from abc import ABCMeta, abstractmethod
from datetime import datetime, timedelta
from distutils.spawn import find_executable
@@ -1452,8 +1451,26 @@
requirements = "requirements_safari.txt"
def _find_downloads(self):
- def text_content(e):
- return etree.tostring(e, encoding="unicode", method="text")
+ def text_content(e, __output=None):
+ # this doesn't use etree.tostring so that we can add spaces for p and br
+ if __output is None:
+ __output = []
+
+ if e.tag == "p":
+ __output.append("\n\n")
+
+ if e.tag == "br":
+ __output.append("\n")
+
+ if e.text is not None:
+ __output.append(e.text)
+
+ for child in e:
+ text_content(child, __output)
+ if child.tail is not None:
+ __output.append(child.tail)
+
+ return "".join(__output)
self.logger.info("Finding STP download URLs")
resp = get("https://developer.apple.com/safari/download/")
@@ -1472,38 +1489,50 @@
if {"download", "dmg", "zip"} & class_names:
downloads.append(candidate)
- """
- When converting to string with text_content, it converts <br> to no space.
- For example:
- Input: Safari Technology Preview<br>for macOS Ventura
- Output: Safari Technology Previewfor macOS Ventura
- """
- stp_link_text = re.compile(r"^\s*Safari\s+Technology\s+Preview\s*(?:[0-9]+\s+)?for\s+macOS")
+ # Note we use \s throughout for space as we don't care what form the whitespace takes
+ stp_link_text = re.compile(
+ r"^\s*Safari\s+Technology\s+Preview\s+(?:[0-9]+\s+)?for\s+macOS"
+ )
requirement = re.compile(
- r"Requires\s+macOS\s+([0-9\.]+)\s+(?:or\s+later|beta)."
+ r"""(?x) # (extended regexp syntax for comments)
+ ^\s*Requires\s+macOS\s+ # Starting with the magic string
+ ([0-9\.]+) # A macOS version number of numbers and dots
+ (?:\s+beta(?:\s+[0-9]+)?)? # Optionally a beta, itself optionally with a number (no dots!)
+ (?:\s+or\s+later)? # Optionally an 'or later'
+ \.\s*$ # Ending with a literal dot
+ """
)
stp_downloads = []
for download in downloads:
for link in download.iterfind(".//a[@href]"):
- if stp_link_text.match(text_content(link)):
+ if stp_link_text.search(text_content(link)):
break
+ else:
+ self.logger.debug("non-matching anchor: " + text_content(link))
else:
continue
- m = requirement.search(text_content(download))
- if m:
- version = m.group(1)
+ for el in download.iter():
+ # avoid assuming any given element here, just assume it is a single element
+ m = requirement.search(text_content(el))
+ if m:
+ version = m.group(1)
- # This assumes the current macOS numbering, whereby X.Y is compatible
- # with X.(Y+1), e.g. 12.4 is compatible with 12.3, but 13.0 isn't
- # compatible with 12.3. This doesn't handle the former 10.* numbering.
- if "." in version:
- spec = SpecifierSet(f"~={version}")
- else:
- spec = SpecifierSet(f"=={version}.*")
+ # This assumes the current macOS numbering, whereby X.Y is compatible
+ # with X.(Y+1), e.g. 12.4 is compatible with 12.3, but 13.0 isn't
+ # compatible with 12.3.
+ if version.count(".") >= (2 if version.startswith("10.") else 1):
+ spec = SpecifierSet(f"~={version}")
+ else:
+ spec = SpecifierSet(f"=={version}.*")
- stp_downloads.append((spec, link.attrib["href"]))
+ stp_downloads.append((spec, link.attrib["href"]))
+ break
+ else:
+ self.logger.debug(
+ "Found a link but no requirement: " + text_content(download)
+ )
if stp_downloads:
self.logger.info(
diff --git a/tools/wpt/tests/safari-downloads/2018-05-17.html b/tools/wpt/tests/safari-downloads/2018-05-17.html
new file mode 100644
index 0000000..950b539
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2018-05-17.html
@@ -0,0 +1,30 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS and
+ experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/091-82859-20180516-222E2B66-E7F2-410F-AA71-A27B03AB84F6/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS High Sierra</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.13.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/091-84914-20180516-222E2B66-E7F2-410F-AA71-A27B03AB84F6/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Sierra</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.12.6 or later.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2018-09-19.html b/tools/wpt/tests/safari-downloads/2018-09-19.html
new file mode 100644
index 0000000..5c00c72
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2018-09-19.html
@@ -0,0 +1,33 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/041-04649-20180910-76E7269A-B217-11E8-B40C-C08B7A641E38/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Mojave</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.14 beta.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/041-04652-20180910-76E7269A-B217-11E8-B40C-C08B7A641E38/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS High Sierra</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.13.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2020-06-04.html b/tools/wpt/tests/safari-downloads/2020-06-04.html
new file mode 100644
index 0000000..49ac12d
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2020-06-04.html
@@ -0,0 +1,33 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/001-09514-20200527-05f7a42c-d9a0-4a60-ba12-97f2145db993/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Catalina</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.15.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/001-09573-20200527-5319cd41-1eb4-412a-817a-bf376957b539/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Mojave</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.14.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2020-07-16.html b/tools/wpt/tests/safari-downloads/2020-07-16.html
new file mode 100644
index 0000000..2c376cc
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2020-07-16.html
@@ -0,0 +1,36 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/001-22645-20200715-da14bc37-e5e6-4790-9e99-0b9d54293dd4/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Big Sur</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 11 beta.</span
+ ><span class="smaller lighter nowrap nowrap-small"
+ >Note: A known issue prevents this release of Safari Technology Preview
+ from working on DTK units.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/001-26262-20200715-7968c880-7e9c-4ea5-9f90-f337c51066d8/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Catalina</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.15.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2020-11-14.html b/tools/wpt/tests/safari-downloads/2020-11-14.html
new file mode 100644
index 0000000..a02d94d
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2020-11-14.html
@@ -0,0 +1,33 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/001-62679-20201022-42e0d63a-527a-45af-beb1-02cd4095e341/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Big Sur</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 11 beta.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/001-62651-20201022-6cd92e18-bfbe-48cc-9385-d84da8f3c24c/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Catalina</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.15.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2021-06-08.html b/tools/wpt/tests/safari-downloads/2021-06-08.html
new file mode 100644
index 0000000..bfba2a7
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2021-06-08.html
@@ -0,0 +1,33 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/071-45899-20210526-3fe7359c-0f20-4850-b6ec-da9b197119c2/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Big Sur</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 11.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/071-44527-20210526-93430244-0334-4fae-878d-56502a656003/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Catalina</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 10.15.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2021-10-28.html b/tools/wpt/tests/safari-downloads/2021-10-28.html
new file mode 100644
index 0000000..36f6b0e
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2021-10-28.html
@@ -0,0 +1,31 @@
+<div class="column large-7 small-12 gutter padding-bottom-small">
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/002-26657-20211027-0354AC04-106E-4389-8084-861E45C1DC98/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Monterey</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 12 beta.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/002-26659-20211027-D948F693-7DCB-4C54-AA93-760F7DCB69D6/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Big Sur</a
+ ><br /><span class="smaller lighter">Requires macOS 11.</span>
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2022-05-29.html b/tools/wpt/tests/safari-downloads/2022-05-29.html
new file mode 100644
index 0000000..b95b27b
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2022-05-29.html
@@ -0,0 +1,44 @@
+<div class="callout">
+ <figure
+ class="app-icon large-icon safari-preview-icon"
+ aria-hidden="true"></figure>
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-08405-20220525-72BCCE23-C6E8-460A-851A-A29AC9C9BCF7/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Monterey</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 12.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-08529-20220525-85875EC7-E4B8-4F5A-9571-85C51D6E381D/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Big Sur</a
+ ><br /><span class="smaller lighter">Requires macOS 11.</span>
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+ <div class="row gutter text-left">
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Release</p>
+ <p class="smaller lighter no-margin">146</p>
+ </div>
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Posted</p>
+ <p class="smaller lighter no-margin">May 25, 2022</p>
+ </div>
+ </div>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2022-06-22.html b/tools/wpt/tests/safari-downloads/2022-06-22.html
new file mode 100644
index 0000000..c019ff9
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2022-06-22.html
@@ -0,0 +1,46 @@
+<div class="callout">
+ <figure
+ class="app-icon large-icon safari-preview-icon"
+ aria-hidden="true"></figure>
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-30324-20220621-99D72AEC-A0E2-4B48-8AC0-B567E3FD046B/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Ventura</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 13 beta.</span
+ >
+ </li>
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-15389-20220621-FA8B8AC9-0442-432C-80B6-6016AB193FCA/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview for macOS Monterey</a
+ ><br /><span class="smaller lighter"
+ >Requires macOS 12.3 or later.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+ <div class="row gutter text-left">
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Release</p>
+ <p class="smaller lighter no-margin">147</p>
+ </div>
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Posted</p>
+ <p class="smaller lighter no-margin">June 21, 2022</p>
+ </div>
+ </div>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2022-07-05.html b/tools/wpt/tests/safari-downloads/2022-07-05.html
new file mode 100644
index 0000000..18bd245
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2022-07-05.html
@@ -0,0 +1,37 @@
+<div class="callout">
+ <figure
+ class="app-icon large-icon safari-preview-icon"
+ aria-hidden="true"></figure>
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-32918-20220629-B3452905-0138-4CA9-A4E6-334B63585653/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview 148 for macOS Monterey</a
+ ><br /><span class="smaller lighter"
+ >Requires macOS 12.3 or later.</span
+ >
+ </li>
+ <li class="document">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+ <div class="row gutter text-left">
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Release</p>
+ <p class="smaller lighter no-margin">148</p>
+ </div>
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Posted</p>
+ <p class="smaller lighter no-margin">June 29, 2022</p>
+ </div>
+ </div>
+</div>
diff --git a/tools/wpt/tests/safari-downloads/2022-07-07.html b/tools/wpt/tests/safari-downloads/2022-07-07.html
new file mode 100644
index 0000000..f73c9ad
--- /dev/null
+++ b/tools/wpt/tests/safari-downloads/2022-07-07.html
@@ -0,0 +1,46 @@
+<div class="callout">
+ <figure
+ class="app-icon large-icon safari-preview-icon"
+ aria-hidden="true"></figure>
+ <h4>Safari Technology Preview</h4>
+ <p class="margin-bottom-small">
+ Get a sneak peek at upcoming web technologies in macOS and iOS with
+ <a href="/safari/technology-preview/" class="nowrap"
+ >Safari Technology Preview</a
+ >
+ and experiment with these technologies in your websites and extensions.
+ </p>
+ <ul class="links small">
+ <li class="dmg">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-38225-20220706-237860CD-5766-4F53-AAC7-1CE26023A959/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview<br />for macOS Ventura</a
+ ><br /><span class="smaller lighter nowrap nowrap-small"
+ >Requires macOS 13 beta 3 or later.</span
+ >
+ </li>
+ <li class="dmg margin-top-small">
+ <a
+ class="inline"
+ href="https://secure-appldnld.apple.com/STP/012-32918-20220629-B3452905-0138-4CA9-A4E6-334B63585653/SafariTechnologyPreview.dmg"
+ >Safari Technology Preview<br />for macOS Monterey</a
+ ><br /><span class="smaller lighter"
+ >Requires macOS 12.3 or later.</span
+ >
+ </li>
+ <li class="document margin-top-small">
+ <a href="/safari/technology-preview/release-notes/">Release Notes</a>
+ </li>
+ </ul>
+ <div class="row gutter text-left">
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Release</p>
+ <p class="smaller lighter no-margin">148</p>
+ </div>
+ <div class="column">
+ <p class="sosumi no-margin-bottom margin-top-small">Posted</p>
+ <p class="smaller lighter no-margin">June 29, 2022</p>
+ </div>
+ </div>
+</div>
diff --git a/tools/wpt/tests/safari_downloads_page_stp_section.html b/tools/wpt/tests/safari_downloads_page_stp_section.html
deleted file mode 100644
index a19e464..0000000
--- a/tools/wpt/tests/safari_downloads_page_stp_section.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<div class="column large-6 medium-12 small-12">
- <div class="callout">
- <figure class="app-icon large-icon safari-preview-icon" aria-hidden="true" data-hires-status="pending"></figure>
- <h4>Safari Technology Preview</h4>
- <p class="margin-bottom-small">Get a sneak peek at upcoming web technologies in macOS and iOS with <a href="/safari/technology-preview/" class="nowrap">Safari Technology Preview</a> and experiment with these technologies in your websites and extensions.</p>
- <ul class="links small">
- <li class="dmg" data-hires-status="pending"><a class="inline" href="https://secure-appldnld.apple.com/STP/012-38225-20220706-237860CD-5766-4F53-AAC7-1CE26023A959/SafariTechnologyPreview.dmg">Safari Technology Preview<br>for macOS Ventura</a><br><span class="smaller lighter nowrap nowrap-small">Requires macOS 13 beta 3 or later.</span></li>
- <li class="dmg margin-top-small" data-hires-status="pending"><a class="inline" href="https://secure-appldnld.apple.com/STP/012-32918-20220629-B3452905-0138-4CA9-A4E6-334B63585653/SafariTechnologyPreview.dmg">Safari Technology Preview<br>for macOS Monterey</a><br><span class="smaller lighter">Requires macOS 12.3 or later.</span></li>
- <li class="document margin-top-small" data-hires-status="pending"><a href="/safari/technology-preview/release-notes/">Release Notes</a></li>
- </ul>
- <div class="row gutter text-left">
- <div class="column">
- <p class="sosumi no-margin-bottom margin-top-small">Release</p>
- <p class="smaller lighter no-margin">148</p>
- </div>
- <div class="column">
- <p class="sosumi no-margin-bottom margin-top-small">Posted</p>
- <p class="smaller lighter no-margin">June 29, 2022</p>
- </div>
- </div>
- </div>
-</div>
\ No newline at end of file
diff --git a/tools/wpt/tests/test_browser.py b/tools/wpt/tests/test_browser.py
index a61d1b1..4c68d75 100644
--- a/tools/wpt/tests/test_browser.py
+++ b/tools/wpt/tests/test_browser.py
@@ -196,37 +196,130 @@
mocked_check_output.side_effect = subprocess.CalledProcessError(1, 'cmd')
assert safari.version(webdriver_binary="safaridriver") is None
-@pytest.fixture
-def safari_downloads_page_stp_section():
- file_path = os.path.join(
- os.path.dirname(__file__),
- 'safari_downloads_page_stp_section.html')
- with open(file_path) as fp:
- return fp.read()
-@mock.patch('tools.wpt.browser.get')
-def test_safari_find_downloads_stp(mocked_get, safari_downloads_page_stp_section):
+@pytest.mark.parametrize(
+ "page_path",
+ sorted(
+ p.path
+ for p in os.scandir(os.path.join(os.path.dirname(__file__), "safari-downloads"))
+ if p.name.endswith(".html")
+ ),
+)
+@mock.patch("tools.wpt.browser.get")
+def test_safari_find_downloads_stp(mocked_get, page_path):
safari = browser.Safari(logger)
# Setup mock
response = requests.models.Response()
response.status_code = 200
- response._content = str.encode(safari_downloads_page_stp_section)
+ response.encoding = "utf-8"
+ with open(page_path, "rb") as fp:
+ response._content = fp.read()
mocked_get.return_value = response
downloads = safari._find_downloads()
- # STP section has two downloads.
- # 1 for Beta Mac OS and 1 for the stable Mac OS
+ if page_path.endswith(
+ (
+ "2022-07-05.html",
+ )
+ ):
+ # occasionally STP is only shipped for a single OS version
+ assert len(downloads) == 1
+ else:
+ assert len(downloads) == 2
+
+
+@mock.patch("tools.wpt.browser.get")
+def test_safari_find_downloads_stp_20180517(mocked_get):
+ safari = browser.Safari(logger)
+ page_path = os.path.join(os.path.dirname(__file__), "safari-downloads", "2018-05-17.html")
+
+ # Setup mock
+ response = requests.models.Response()
+ response.status_code = 200
+ response.encoding = "utf-8"
+ with open(page_path, "rb") as fp:
+ response._content = fp.read()
+ mocked_get.return_value = response
+
+ downloads = safari._find_downloads()
+
assert len(downloads) == 2
- # First section is for beta OS version
- assert downloads[0][0] == SpecifierSet("==13.*")
- assert "13.0" in downloads[0][0]
+ assert downloads[0][0] == SpecifierSet("==10.13.*")
+ assert "10.12" not in downloads[0][0]
+ assert "10.13" in downloads[0][0]
+ assert "10.13.3" in downloads[0][0]
+ assert "10.14" not in downloads[0][0]
- # Second section is for the stable OS version
+ assert downloads[1][0] == SpecifierSet("~=10.12.6")
+ assert "10.12" not in downloads[1][0]
+ assert "10.12.6" in downloads[1][0]
+ assert "10.12.9" in downloads[1][0]
+ assert "10.13" not in downloads[1][0]
+
+
+@mock.patch("tools.wpt.browser.get")
+def test_safari_find_downloads_stp_20220529(mocked_get):
+ safari = browser.Safari(logger)
+ page_path = os.path.join(os.path.dirname(__file__), "safari-downloads", "2022-05-29.html")
+
+ # Setup mock
+ response = requests.models.Response()
+ response.status_code = 200
+ response.encoding = "utf-8"
+ with open(page_path, "rb") as fp:
+ response._content = fp.read()
+ mocked_get.return_value = response
+
+ downloads = safari._find_downloads()
+
+ assert len(downloads) == 2
+
+ assert downloads[0][0] == SpecifierSet("==12.*")
+ assert "11.4" not in downloads[0][0]
+ assert "12.0" in downloads[0][0]
+ assert "12.5" in downloads[0][0]
+ assert "13.0" not in downloads[0][0]
+
+ assert downloads[1][0] == SpecifierSet("==11.*")
+ assert "10.15.7" not in downloads[1][0]
+ assert "11.0.1" in downloads[1][0]
+ assert "11.3" in downloads[1][0]
+ assert "11.5" in downloads[1][0]
+ assert "12.0" not in downloads[1][0]
+
+
+@mock.patch("tools.wpt.browser.get")
+def test_safari_find_downloads_stp_20220707(mocked_get):
+ safari = browser.Safari(logger)
+ page_path = os.path.join(os.path.dirname(__file__), "safari-downloads", "2022-07-07.html")
+
+ # Setup mock
+ response = requests.models.Response()
+ response.status_code = 200
+ response.encoding = "utf-8"
+ with open(page_path, "rb") as fp:
+ response._content = fp.read()
+ mocked_get.return_value = response
+
+ downloads = safari._find_downloads()
+
+ assert len(downloads) == 2
+
+ assert downloads[0][0] == SpecifierSet("==13.*")
+ assert "12.4" not in downloads[0][0]
+ assert "13.0" in downloads[0][0]
+ assert "13.5" in downloads[0][0]
+ assert "14.0" not in downloads[0][0]
+
assert downloads[1][0] == SpecifierSet("~=12.3")
- assert "12.4" in downloads[1][0]
+ assert "11.5" not in downloads[1][0]
+ assert "12.2" not in downloads[1][0]
+ assert "12.3" in downloads[1][0]
+ assert "12.5" in downloads[1][0]
+ assert "13.0" not in downloads[1][0]
@mock.patch('subprocess.check_output')