diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/annotation-model/tools | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
24 files changed, 462 insertions, 0 deletions
diff --git a/testing/web-platform/tests/annotation-model/tools/make_tests.py b/testing/web-platform/tests/annotation-model/tools/make_tests.py new file mode 100644 index 0000000000..6890baa296 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/make_tests.py @@ -0,0 +1,100 @@ +# This tool creates .html test files for the WPT harness from corresponding .test +# files that it finds in the tree for this test collection. + +import re +import time +import json +import fnmatch +import os +import shutil +import sys +import argparse + +TESTTREE = '..' +DEFDIR = '../definitions' +MANUAL_TEMPLATE = 'template_manual' +JS_TEMPLATE = 'template_js' + +parser = argparse.ArgumentParser() + +parser.add_argument('--examples', action="store_const", const=1) + +args = parser.parse_args() + +# pull in the template + +manualTemplate = open(MANUAL_TEMPLATE, "r").read() +autoTemplate = open(JS_TEMPLATE, "r").read() + +defList = [] +defnames = "" + +# find all of the definitions +for curdir, subdirList, fileList in os.walk(DEFDIR, topdown=True): + for file in fnmatch.filter(fileList, "*.json"): + theFile = os.path.join(curdir, file) + try: + testJSON = json.load(open(theFile, "r")) + except ValueError as e: + print("parse of " + theFile + " failed: " + e[0]) + else: + theFile = re.sub("\.\./", "", theFile) + defList.append(theFile) + +if (len(defList)): + defNames = '"' + '",\n "'.join(defList) + '"' + + +# iterate over the folders looking for .test files + +for curdir, subdirList, fileList in os.walk(TESTTREE, topdown=True): + # skip the definitions directory + subdirList[:] = [d for d in subdirList if d != "definitions"] + # skip the examples directory + if args.examples != 1: + subdirList[:] = [d for d in subdirList if d != "examples"] + + for file in fnmatch.filter(fileList, "*.test"): +# for each .test file, create a corresponding .html file using the appropriate +# template + theFile = os.path.join(curdir, file) + try: + testJSON = json.load(open(theFile, "r")) + except ValueError as e: + print("parse of " + theFile + " failed: " + e[0]) + else: + try: + testType = testJSON['testType'] + except: + testType = "manual" + + templateFile = manualTemplate + suffix = "-manual.html" + + if testType == "automated": + templateFile = autoTemplate + suffix = ".html" + + rfile = re.sub("\.\./", "", file) + # interesting pattern is {{TESTFILE}} + tcopy = re.sub("{{TESTFILE}}", rfile, templateFile) + + tcopy = re.sub("{{SCHEMADEFS}}", defNames, tcopy) + + try: + title = testJSON['name'] + except: + title = file + tcopy = re.sub("{{TESTTITLE}}", title, tcopy) + + # target file is basename of theFile + '-manual.html' + target = re.sub("\.test",suffix, theFile) + + try: + out = open(target, "w") + out.write(tcopy) + out.close() + except: + print("Failed to create "+target) + else: + print("Created " + target) diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example1.json b/testing/web-platform/tests/annotation-model/tools/samples/example1.json new file mode 100644 index 0000000000..905349bb46 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example1.json @@ -0,0 +1,7 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno1", + "type": "Annotation", + "body": "http://example.org/post1", + "target": "http://example.com/page1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example10.json b/testing/web-platform/tests/annotation-model/tools/samples/example10.json new file mode 100644 index 0000000000..766fddf3ac --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example10.json @@ -0,0 +1,19 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno10", + "type": "Annotation", + "body": { + "type": "Choice", + "items": [ + { + "id": "http://example.org/note1", + "language": "en" + }, + { + "id": "http://example.org/note2", + "language": "fr" + } + ] + }, + "target": "http://example.org/website1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example11.json b/testing/web-platform/tests/annotation-model/tools/samples/example11.json new file mode 100644 index 0000000000..7461493f46 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example11.json @@ -0,0 +1,18 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno11", + "type": "Annotation", + "motivation": "commenting", + "body": { + "type": "TextualBody", + "value": "These pages together provide evidence of the conspiracy" + }, + "target": { + "type": "Composite", + "items": [ + "http://example.com/page1", + "http://example.org/page6", + "http://example.net/page4" + ] + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example12.json b/testing/web-platform/tests/annotation-model/tools/samples/example12.json new file mode 100644 index 0000000000..a8039b207d --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example12.json @@ -0,0 +1,19 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno12", + "type": "Annotation", + "motivation": "tagging", + "body": { + "type": "TextualBody", + "value": "important" + }, + "target": { + "type": "List", + "items": [ + "http://example.com/book/page1", + "http://example.com/book/page2", + "http://example.com/book/page3", + "http://example.com/book/page4" + ] + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example13.json b/testing/web-platform/tests/annotation-model/tools/samples/example13.json new file mode 100644 index 0000000000..8bf663330d --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example13.json @@ -0,0 +1,16 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno13", + "type": "Annotation", + "motivation": "classifying", + "body": "http://example.org/vocab/art/portrait", + "target": { + "type": "Independents", + "items": [ + "http://example.com/image1", + "http://example.net/image2", + "http://example.com/image4", + "http://example.org/image9" + ] + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example14.json b/testing/web-platform/tests/annotation-model/tools/samples/example14.json new file mode 100644 index 0000000000..7f8d2b8393 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example14.json @@ -0,0 +1,16 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno14", + "type": "Annotation", + "creator": "http://example.org/user1", + "created": "2015-01-28T12:00:00Z", + "modified": "2015-01-29T09:00:00Z", + "generator": "http://example.org/client1", + "generated": "2015-02-04T12:00:00Z", + "body": { + "id": "http://example.net/review1", + "creator": "http://example.net/user2", + "created": "2014-06-02T17:00:00Z" + }, + "target": "http://example.com/restaurant1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example15.json b/testing/web-platform/tests/annotation-model/tools/samples/example15.json new file mode 100644 index 0000000000..1280eef4cd --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example15.json @@ -0,0 +1,20 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno15", + "type": "Annotation", + "creator": { + "id": "http://example.org/user1", + "type": "Person", + "name": "My Pseudonym", + "nickname": "pseudo", + "email_sha1": "58bad08927902ff9307b621c54716dcc5083e339" + }, + "generator": { + "id": "http://example.org/client1", + "type": "Software", + "name": "Code v2.1", + "homepage": "http://example.org/client1/homepage1" + }, + "body": "http://example.net/review1", + "target": "http://example.com/restaurant1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example16.json b/testing/web-platform/tests/annotation-model/tools/samples/example16.json new file mode 100644 index 0000000000..f110169c34 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example16.json @@ -0,0 +1,12 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno16", + "type": "Annotation", + "audience": { + "id": "http://example.edu/roles/teacher", + "type": "schema:EducationalAudience", + "schema:educationalRole": "teacher" + }, + "body": "http://example.net/classnotes1", + "target": "http://example.com/textbook1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example17.json b/testing/web-platform/tests/annotation-model/tools/samples/example17.json new file mode 100644 index 0000000000..056b8e4f53 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example17.json @@ -0,0 +1,12 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno17", + "type": "Annotation", + "motivation": "commenting", + "body": "http://example.net/comment1", + "target": { + "id": "http://example.com/video1", + "type": "Video", + "accessibility": "captions" + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example18.json b/testing/web-platform/tests/annotation-model/tools/samples/example18.json new file mode 100644 index 0000000000..cdf50fcd8f --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example18.json @@ -0,0 +1,19 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno18", + "type": "Annotation", + "motivation": "bookmarking", + "body": [ + { + "type": "TextualBody", + "value": "readme", + "purpose": "tagging" + }, + { + "type": "TextualBody", + "value": "A good description of the topic that bears further investigation", + "purpose": "describing" + } + ], + "target": "http://example.com/page1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example19.json b/testing/web-platform/tests/annotation-model/tools/samples/example19.json new file mode 100644 index 0000000000..bd572ce688 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example19.json @@ -0,0 +1,11 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno19", + "type": "Annotation", + "rights": "https://creativecommons.org/publicdomain/zero/1.0/", + "body": { + "id": "http://example.net/review1", + "rights": "http://creativecommons.org/licenses/by-nc/4.0/" + }, + "target": "http://example.com/product1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example2.json b/testing/web-platform/tests/annotation-model/tools/samples/example2.json new file mode 100644 index 0000000000..f950f2db8d --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example2.json @@ -0,0 +1,17 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno2", + "type": "Annotation", + "body": { + "id": "http://example.org/analysis1.mp3", + "format": "audio/mpeg", + "language": "fr" + }, + "target": { + "id": "http://example.gov/patent1.pdf", + "format": "application/pdf", + "language": ["en", "ar"], + "textDirection": "ltr", + "processingLanguage": "en" + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example20.json b/testing/web-platform/tests/annotation-model/tools/samples/example20.json new file mode 100644 index 0000000000..17fcc7185a --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example20.json @@ -0,0 +1,12 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno20", + "type": "Annotation", + "canonical": "urn:uuid:dbfb1861-0ecf-41ad-be94-a584e5c4f1df", + "via": "http://other.example.org/anno1", + "body": { + "id": "http://example.net/review1", + "rights": "http://creativecommons.org/licenses/by/4.0/" + }, + "target": "http://example.com/product1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example3.json b/testing/web-platform/tests/annotation-model/tools/samples/example3.json new file mode 100644 index 0000000000..c390905ebb --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example3.json @@ -0,0 +1,13 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno3", + "type": "Annotation", + "body": { + "id": "http://example.org/video1", + "type": "Video" + }, + "target": { + "id": "http://example.org/website1", + "type": "Text" + } +} diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example4.json b/testing/web-platform/tests/annotation-model/tools/samples/example4.json new file mode 100644 index 0000000000..5655fb39e1 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example4.json @@ -0,0 +1,11 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno4", + "type": "Annotation", + "body": "http://example.org/description1", + "target": { + "id": "http://example.com/image1#xywh=100,100,300,300", + "type": "Image", + "format": "image/jpeg" + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example5.json b/testing/web-platform/tests/annotation-model/tools/samples/example5.json new file mode 100644 index 0000000000..85532e8785 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example5.json @@ -0,0 +1,12 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno5", + "type":"Annotation", + "body": { + "type" : "TextualBody", + "value" : "<p>j'adore !</p>", + "format" : "text/html", + "language" : "fr" + }, + "target": "http://example.org/photo1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example6.json b/testing/web-platform/tests/annotation-model/tools/samples/example6.json new file mode 100644 index 0000000000..9ae0d88eae --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example6.json @@ -0,0 +1,7 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno6", + "type":"Annotation", + "bodyValue": "Comment text", + "target": "http://example.org/target1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example7.json b/testing/web-platform/tests/annotation-model/tools/samples/example7.json new file mode 100644 index 0000000000..9f821d22fb --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example7.json @@ -0,0 +1,11 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno7", + "type":"Annotation", + "body": { + "type": "TextualBody", + "value": "Comment text", + "format": "text/plain" + }, + "target": "http://example.org/target1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example8.json b/testing/web-platform/tests/annotation-model/tools/samples/example8.json new file mode 100644 index 0000000000..3187af6574 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example8.json @@ -0,0 +1,6 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno8", + "type": "Annotation", + "target": "http://example.org/ebook1" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/samples/example9.json b/testing/web-platform/tests/annotation-model/tools/samples/example9.json new file mode 100644 index 0000000000..8d72da3563 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/samples/example9.json @@ -0,0 +1,16 @@ +{ + "@context": "http://www.w3.org/ns/anno.jsonld", + "id": "http://example.org/anno9", + "type": "Annotation", + "body": [ + "http://example.org/description1", + { + "type": "TextualBody", + "value": "tag1" + } + ], + "target": [ + "http://example.org/image1", + "http://example.org/image2" + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/annotation-model/tools/template_js b/testing/web-platform/tests/annotation-model/tools/template_js new file mode 100644 index 0000000000..29b76b323f --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/template_js @@ -0,0 +1,36 @@ +<!doctype html> +<html> +<head> +<title>{{TESTTITLE}}</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/annotation-model/scripts/ajv.min.js"></script> +<script src="/annotation-model/scripts/JSONtest.js"></script> +<script> +setup( { explicit_done: true } ); + +var theDefinitions=[ + {{SCHEMADEFS}} +]; + +var theTestFile="{{TESTFILE}}"; + +var runningTest = new JSONtest( { + "schemaDefs" : theDefinitions, + "testFile" : theTestFile +} ) ; + +var c; + +runningTest.Promise.then(function(test) { + test.runTests(test.Assertions, test.Test.content); + done(); +}); +</script> +</head> +<body> +<div id="testDescription"></div> +<p>The following assertions are being evaluated:</p> +<div id="assertion"></div> +</body> +</html> diff --git a/testing/web-platform/tests/annotation-model/tools/template_manual b/testing/web-platform/tests/annotation-model/tools/template_manual new file mode 100644 index 0000000000..14b3b9aa8b --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/template_manual @@ -0,0 +1,42 @@ +<!doctype html> +<html> +<head> +<title>{{TESTTITLE}}</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/annotation-model/scripts/ajv.min.js"></script> +<script src="/annotation-model/scripts/showdown.min.js"></script> +<script src="/annotation-model/scripts/JSONtest.js"></script> +<script> +setup({explicit_timeout: true, explicit_done: true }); + +var theDefinitions=[ + {{SCHEMADEFS}} +]; + +var theTestFile="{{TESTFILE}}"; + +var runningTest = new JSONtest( { + "testInput" : "annotation-input", + "runTest" : "annotation-run", + "closeWindow" : "annotation-close", + "schemaDefs" : theDefinitions, + "testFile" : theTestFile +} ) ; + +</script> +</head> +<body> +<p>Fill the textarea below with JSON output from your annotation client +implementation that supports the following criteria:</p> +<div id="testDescription"></div> +<form name="annotation" id="annotation"> + <textarea name="annotation-input" id="annotation-input" style="width: 90%; height: 10em" ></textarea> + <p><input type="button" id="annotation-run" name="Loading..." value="Loading..."> + <input style="display: none" type="button" id="annotation-close" + name="Close" value="Close"></p> +</form> +<p>Specifically, the following assertions will be evaluated:</p> +<div id="assertion"></div> +</body> +</html> diff --git a/testing/web-platform/tests/annotation-model/tools/tests/README.md b/testing/web-platform/tests/annotation-model/tools/tests/README.md new file mode 100644 index 0000000000..92e4f97c73 --- /dev/null +++ b/testing/web-platform/tests/annotation-model/tools/tests/README.md @@ -0,0 +1,10 @@ +Tree to Test the Tests +====================== + +This folder is meant to contain a collection of .jsonld files that mirror the +structure of the top level folders and subfolders with .test files. A script +(@@@TODO@@@) will walk this tree, taking each folder and running it through the +corresponding .test file to ensure that the test is working as expected. An +argument to that script will report on any .jsonld files that do not have a +corresponding .test file, and vice versa. + |