diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9e29e884..0622a808 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- An invidious instance "fetch with CORS" test
+
### Fixed
- a bug where public Invidious instances all showed `N/A` in the health column
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml
index 61357abd..c0b920b6 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTesting.xml
@@ -38,7 +38,7 @@
iconVisible="false"
anchor="[0.5,0.5]"
padding="[30,30]"
- translation="[580,530]" />
+ translation="[580,545]" />
\ No newline at end of file
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs
index ea0c02c2..69bae1e5 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingTask.bs
@@ -32,6 +32,7 @@ function PrepareTests() as object
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoComments), CanFetchVideoComments))
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoCaptions), CanFetchVideoCaptions))
content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchVideoThumbnails), CanFetchVideoThumbails))
+ content.AppendChild(CreateTestNode(Tr(Locale.InvidiousTesting.FetchWithCors), CanFetchWithCors))
return content
end function
@@ -312,3 +313,37 @@ function CanFetchVideoThumbails(instance as string, testNode as object, cancella
testNode.details = ErrorUtils.Format(e)
end try
end function
+
+function CanFetchWithCors(instance as string, testNode as object, cancellation as object) as void
+ try
+ url = `${instance}/api/v1/trending`
+ response = HttpClient.Get(url).NoCache().Cancellation(cancellation).Await()
+
+ if not response.IsSuccess()
+ testNode.state = "failed"
+ testNode.details = response.ErrorMessage()
+ return
+ end if
+
+ json = response.Json()
+ if json = invalid
+ testNode.state = "failed"
+ testNode.details = Tr(Locale.InvidiousTesting.InvalidJsonFrom).Replace("%1", url)
+ return
+ end if
+
+ headers = response.Headers()
+ corsHeader = headers["Access-Control-Allow-Origin"]
+ if not IsString(corsHeader) or corsHeader <> "*"
+ testNode.state = "failed"
+ testNode.details = Tr(Locale.InvidiousTesting.CorsHeaderNotSetCorrectly).Replace("%1", url)
+ return
+ end if
+
+ testNode.state = "passed"
+ testNode.details = Tr(Locale.InvidiousTesting.TheInstanceCanFetchWithCors).Replace("%1", url)
+ catch e
+ testNode.state = "failed"
+ testNode.details = ErrorUtils.Format(e)
+ end try
+end function
diff --git a/playlet-lib/src/locale/en_US/translations.ts b/playlet-lib/src/locale/en_US/translations.ts
index 971459dc..695a2c8c 100644
--- a/playlet-lib/src/locale/en_US/translations.ts
+++ b/playlet-lib/src/locale/en_US/translations.ts
@@ -364,6 +364,10 @@
Fetch video thumbnailsFetch video thumbnails
+
+ Fetch with CORS
+ Fetch with CORS
+ Press 'OK' for detailsPress 'OK' for details
@@ -432,6 +436,14 @@
The instance can fetch video thumbnail for ID %1 (%2)The instance can fetch video thumbnail for ID %1 (%2)
+
+ CORS header not set correctly from %1
+ CORS header not set correctly from %1
+
+
+ The instance can fetch with CORS from %1
+ The instance can fetch with CORS from %1
+ PassedPassed
diff --git a/playlet-lib/src/source/utils/Locale.bs b/playlet-lib/src/source/utils/Locale.bs
index 96815f67..31455969 100644
--- a/playlet-lib/src/source/utils/Locale.bs
+++ b/playlet-lib/src/source/utils/Locale.bs
@@ -118,6 +118,7 @@ namespace Locale
FetchVideoComments = "Fetch video comments"
FetchVideoCaptions = "Fetch video captions"
FetchVideoThumbnails = "Fetch video thumbnails"
+ FetchWithCors = "Fetch with CORS"
PressOkForDetails = "Press 'OK' for details"
@@ -138,6 +139,8 @@ namespace Locale
ThumbnailNotReachable = "%1 is not reachable"
InvalidThumbnailData = "Invalid thumbnail data %1 (Content-Type is not image/*)"
TheInstanceCanFetchVideoThumbnails = "The instance can fetch video thumbnail for ID %1 (%2)"
+ CorsHeaderNotSetCorrectly = "CORS header not set correctly from %1"
+ TheInstanceCanFetchWithCors = "The instance can fetch with CORS from %1"
Passed = "Passed"
Failed = "Failed"