diff --git a/ci/check-environment-variable-names.ps1 b/ci/check-environment-variable-names.ps1 index 694469ce..9070888a 100644 --- a/ci/check-environment-variable-names.ps1 +++ b/ci/check-environment-variable-names.ps1 @@ -28,9 +28,9 @@ $ErrorActionPreference = 'Stop' $script:Prefix = '_51DEGREES_' # Names GitHub, the operating system, Python, pytest and Flask define. Any -# name starting GITHUB_ is GitHub's. +# name starting GITHUB_ is GitHub's, and GitHub sets CI on every runner. $script:PlatformNames = @( - 'FLASK_APP', 'PATH', 'PSModulePath', 'PYTEST_ADDOPTS', 'PYTHON_GIL', + 'CI', 'FLASK_APP', 'PATH', 'PSModulePath', 'PYTEST_ADDOPTS', 'PYTHON_GIL', 'PYTHONPATH', 'TEMP', 'TMP', 'TMPDIR') $script:PlatformPrefixes = @('GITHUB_') diff --git a/device-detection/fiftyone_devicedetection/setup.py b/device-detection/fiftyone_devicedetection/setup.py index e3bd7af0..48b674da 100644 --- a/device-detection/fiftyone_devicedetection/setup.py +++ b/device-detection/fiftyone_devicedetection/setup.py @@ -65,7 +65,7 @@ def read(file_name): python_requires=">=3.10", packages=["fiftyone_devicedetection"], package_dir={"": "src"}, - install_requires=["fiftyone_devicedetection_shared", "fiftyone_devicedetection_cloud", "fiftyone_devicedetection_onpremise"], + install_requires=["fiftyone_devicedetection_shared", "fiftyone_devicedetection_cloud>=4.6.3", "fiftyone_devicedetection_onpremise"], license="EUPL-1.2", classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/device-detection/fiftyone_devicedetection/src/fiftyone_devicedetection/devicedetection_pipelinebuilder.py b/device-detection/fiftyone_devicedetection/src/fiftyone_devicedetection/devicedetection_pipelinebuilder.py index 5527a47c..1dc00459 100644 --- a/device-detection/fiftyone_devicedetection/src/fiftyone_devicedetection/devicedetection_pipelinebuilder.py +++ b/device-detection/fiftyone_devicedetection/src/fiftyone_devicedetection/devicedetection_pipelinebuilder.py @@ -22,6 +22,7 @@ from fiftyone_pipeline_core.pipelinebuilder import PipelineBuilder from fiftyone_pipeline_cloudrequestengine.cloudrequestengine import CloudRequestEngine +from fiftyone_pipeline_cloudrequestengine.browserderived import BrowserDerivedCloud from fiftyone_devicedetection_cloud.devicedetection_cloud import DeviceDetectionCloud from fiftyone_devicedetection_onpremise.devicedetection_onpremise import DeviceDetectionOnPremise from fiftyone_devicedetection_shared.utils import merge_two_dicts @@ -169,6 +170,10 @@ def __init__(self, settings = None, usage_sharing = True, **kwargs): request_engine.set_cache(settings["cache"]) self.add(request_engine) + # browserderived carries the browser tests that come with + # HumanConfidence. They are JavaScript properties, which the + # client script runs. + self.add(BrowserDerivedCloud()) device = DeviceDetectionCloud() self.add(device) diff --git a/device-detection/fiftyone_devicedetection_cloud/readme.md b/device-detection/fiftyone_devicedetection_cloud/readme.md index c41fda5c..7d9139da 100644 --- a/device-detection/fiftyone_devicedetection_cloud/readme.md +++ b/device-detection/fiftyone_devicedetection_cloud/readme.md @@ -26,6 +26,8 @@ fd.process() print(fd.device.ismobile.value()) ``` +The builder also adds a `BrowserDerivedCloud` engine after the cloud request engine. HumanConfidence comes with browser tests, and the engine puts them into the FlowData as JavaScript properties. The client script your server serves then runs them. The engine works from the cloud request engine's response and makes no request of its own. + For more in-depth examples, check out the [examples](https://51degrees.com/device-detection-python/examples.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_devicedetection_cloud&utm_term=from-pypi) page in the documentation. ### From GitHub diff --git a/device-detection/fiftyone_devicedetection_cloud/setup.py b/device-detection/fiftyone_devicedetection_cloud/setup.py index 2f7ce21d..1444acc6 100644 --- a/device-detection/fiftyone_devicedetection_cloud/setup.py +++ b/device-detection/fiftyone_devicedetection_cloud/setup.py @@ -71,7 +71,7 @@ def read(file_name): # profile results of this package are built on. "fiftyone_pipeline_core>=4.5.44", # The release this package is built and tested with. - "fiftyone_pipeline_cloudrequestengine>=4.5.45", + "fiftyone_pipeline_cloudrequestengine>=4.6.3", ], license="EUPL-1.2", classifiers=[ diff --git a/device-detection/fiftyone_devicedetection_cloud/src/fiftyone_devicedetection_cloud/devicedetection_cloud_pipelinebuilder.py b/device-detection/fiftyone_devicedetection_cloud/src/fiftyone_devicedetection_cloud/devicedetection_cloud_pipelinebuilder.py index a20a28ee..d1e23005 100644 --- a/device-detection/fiftyone_devicedetection_cloud/src/fiftyone_devicedetection_cloud/devicedetection_cloud_pipelinebuilder.py +++ b/device-detection/fiftyone_devicedetection_cloud/src/fiftyone_devicedetection_cloud/devicedetection_cloud_pipelinebuilder.py @@ -23,13 +23,17 @@ from __future__ import absolute_import from fiftyone_pipeline_core.pipelinebuilder import PipelineBuilder from fiftyone_pipeline_cloudrequestengine.cloudrequestengine import CloudRequestEngine +from fiftyone_pipeline_cloudrequestengine.browserderived import BrowserDerivedCloud from .devicedetection_cloud import DeviceDetectionCloud from fiftyone_devicedetection_shared.utils import merge_two_dicts class DeviceDetectionCloudPipelineBuilder(PipelineBuilder): """! The Device Detection Pipeline Builder allows you to easily - Construct a pipeline containing the device detection cloud engine + Construct a pipeline containing the device detection cloud engine. + It also adds the browserderived cloud engine after the Cloud Request + Engine, which puts the browser tests into the FlowData as JavaScript + properties for the client script to run. Internal function for getting evidence keys used by cloud engines @@ -91,5 +95,9 @@ def __init__(self, settings = None, usage_sharing = True, **kwargs): request_engine.set_cache(settings["cache"]) self.add(request_engine) + # A request for HumanConfidence gets browser tests back as + # JavaScript properties of browserderived, and the client script + # runs them. + self.add(BrowserDerivedCloud()) self.add(DeviceDetectionCloud()) diff --git a/device-detection/fiftyone_devicedetection_cloud/tests/test_builder_browser_tests.py b/device-detection/fiftyone_devicedetection_cloud/tests/test_builder_browser_tests.py new file mode 100644 index 00000000..6409d845 --- /dev/null +++ b/device-detection/fiftyone_devicedetection_cloud/tests/test_builder_browser_tests.py @@ -0,0 +1,95 @@ +# ********************************************************************* +# This Original Work is copyright of 51 Degrees Mobile Experts Limited. +# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, +# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. +# +# This Original Work is licensed under the European Union Public Licence +# (EUPL) v.1.2 and is subject to its terms as set out below. +# +# If a copy of the EUPL was not distributed with this file, You can obtain +# one at https://opensource.org/licenses/EUPL-1.2. +# +# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be +# amended by the European Commission) shall be deemed incompatible for +# the purposes of the Work and the provisions of the compatibility +# clause in Article 5 of the EUPL shall not apply. +# +# If using the Work as, or as part of, a network application, by +# including the attribution notice(s) required under Article 5 of the EUPL +# in the end user terms of the application under an appropriate heading, +# such notice(s) shall fulfill the requirements of that article. +# ********************************************************************* +"""! +Tests that a pipeline from the Device Detection Cloud Pipeline Builder has +the browserderived cloud engine after the Cloud Request Engine. The user +adds nothing, the browser tests are in the FlowData as JavaScript +properties, and the only request made is the Cloud Request Engine's one. +The names are made up. No network connection or resource key is needed. +""" + +import json +import unittest +from unittest.mock import Mock + +from requests import Response + +from fiftyone_pipeline_cloudrequestengine.requestclient import RequestClient + +from fiftyone_devicedetection_cloud.devicedetection_cloud_pipelinebuilder import DeviceDetectionCloudPipelineBuilder + + +class StandInCloud(RequestClient): + """! + A stand in for the cloud service that counts every request. It has a + browser test with a made-up name and the JavaScript type. + """ + + def __init__(self): + self.requests = [] + + def request(self, type, url, content, originHeader, timeout_seconds=None): + self.requests.append(url) + if "accessibleProperties" in url: + body = {"Products": { + "device": {"Properties": [ + {"Name": "IsMobile", "Type": "Boolean"}]}, + "browserderived": {"Properties": [ + {"Name": "Q7Hx2b", "Type": "JavaScript"}]}}} + elif "evidencekeys" in url: + body = ["header.user-agent", "query.user-agent"] + else: + body = {"device": {"ismobile": False}, + "browserderived": {"q7hx2b": "window.q7=1;"}} + response = Mock(spec=Response) + response.status_code = 200 + response.text = json.dumps(body) + response.content = response.text.encode("utf-8") + response.json = lambda: json.loads(response.text) + return response + + +class BuilderBrowserTestsTests(unittest.TestCase): + + def test_a_cloud_pipeline_carries_the_browser_tests(self): + cloud = StandInCloud() + pipeline = DeviceDetectionCloudPipelineBuilder( + resource_key="a-resource-key", http_client=cloud).build() + self.addCleanup(pipeline.close) + + keys = [element.datakey for element in pipeline.flow_elements] + self.assertEqual(keys.index("cloud") + 1, + keys.index("browserderived")) + properties = pipeline.get_element("browserderived").get_properties() + self.assertEqual("JavaScript", properties["q7hx2b"]["type"]) + + before = len(cloud.requests) + data = pipeline.create_flowdata() + data.evidence.add("header.user-agent", "Mozilla/5.0") + data.process() + self.assertEqual("window.q7=1;", + data.get("browserderived").get("q7hx2b").value()) + self.assertIn("browserderived.q7hx2b", + data.get("jsonbundler").get("json")[ + "javascriptProperties"]) + self.assertEqual(1, len(cloud.requests) - before, + "one request, the data request, and no other") diff --git a/device-detection/fiftyone_devicedetection_cloud/tests/test_cloud.py b/device-detection/fiftyone_devicedetection_cloud/tests/test_cloud.py index 3cd1457d..c133d90b 100644 --- a/device-detection/fiftyone_devicedetection_cloud/tests/test_cloud.py +++ b/device-detection/fiftyone_devicedetection_cloud/tests/test_cloud.py @@ -107,7 +107,6 @@ def test_missing_property_service_element_not_found(self): result = str(raised.exception) self.assertIn("notpresent", result) - self.assertIn("['device']", result) self.assertIn("https://51degrees.com/documentation/_services__cloud__resource_keys.html", result) def test_engine_init_performance(self): diff --git a/device-detection/fiftyone_devicedetection_examples/tests/test_builder_browser_tests.py b/device-detection/fiftyone_devicedetection_examples/tests/test_builder_browser_tests.py new file mode 100644 index 00000000..59b24c37 --- /dev/null +++ b/device-detection/fiftyone_devicedetection_examples/tests/test_builder_browser_tests.py @@ -0,0 +1,94 @@ +# ********************************************************************* +# This Original Work is copyright of 51 Degrees Mobile Experts Limited. +# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, +# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. +# +# This Original Work is licensed under the European Union Public Licence +# (EUPL) v.1.2 and is subject to its terms as set out below. +# +# If a copy of the EUPL was not distributed with this file, You can obtain +# one at https://opensource.org/licenses/EUPL-1.2. +# +# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be +# amended by the European Commission) shall be deemed incompatible for +# the purposes of the Work and the provisions of the compatibility +# clause in Article 5 of the EUPL shall not apply. +# +# If using the Work as, or as part of, a network application, by +# including the attribution notice(s) required under Article 5 of the EUPL +# in the end user terms of the application under an appropriate heading, +# such notice(s) shall fulfill the requirements of that article. +# ********************************************************************* +""" +The Device Detection builder is tested here, as the +fiftyone_devicedetection package has no tests of its own. + +Given a resource key, the builder adds the browserderived cloud engine +after the Cloud Request Engine by itself. The browser tests then reach the +FlowData as JavaScript properties, and the pipeline makes the Cloud Request +Engine's one request and no other. Browser test names are made up. Runs +with no network connection and no resource key. +""" + +import json +import unittest +from unittest.mock import Mock + +from requests import Response + +from fiftyone_pipeline_cloudrequestengine.requestclient import RequestClient + +from fiftyone_devicedetection.devicedetection_pipelinebuilder import DeviceDetectionPipelineBuilder + + +class StandInCloud(RequestClient): + """ + Answers as the cloud service would, with a single browser test typed + JavaScript under a made-up name. Keeps a count of the requests. + """ + + def __init__(self): + self.requests = [] + + def request(self, type, url, content, originHeader, timeout_seconds=None): + self.requests.append(url) + if "accessibleProperties" in url: + body = {"Products": { + "device": {"Properties": [ + {"Name": "IsMobile", "Type": "Boolean"}]}, + "browserderived": {"Properties": [ + {"Name": "Q7Hx2b", "Type": "JavaScript"}]}}} + elif "evidencekeys" in url: + body = ["header.user-agent", "query.user-agent"] + else: + body = {"device": {"ismobile": False}, + "browserderived": {"q7hx2b": "window.q7=1;"}} + response = Mock(spec=Response) + response.status_code = 200 + response.text = json.dumps(body) + response.content = response.text.encode("utf-8") + response.json = lambda: json.loads(response.text) + return response + + +class BuilderBrowserTestsTests(unittest.TestCase): + + def test_a_cloud_pipeline_carries_the_browser_tests(self): + cloud = StandInCloud() + pipeline = DeviceDetectionPipelineBuilder( + resource_key="a-resource-key", http_client=cloud).build() + self.addCleanup(pipeline.close) + + keys = [element.datakey for element in pipeline.flow_elements] + self.assertEqual(keys.index("cloud") + 1, + keys.index("browserderived")) + self.assertLess(keys.index("browserderived"), keys.index("device")) + + before = len(cloud.requests) + data = pipeline.create_flowdata() + data.evidence.add("header.user-agent", "Mozilla/5.0") + data.process() + self.assertEqual("window.q7=1;", + data.get("browserderived").get("q7hx2b").value()) + self.assertEqual(1, len(cloud.requests) - before, + "one request, the data request, and no other") diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/readme.md b/pipeline/fiftyone_pipeline_cloudrequestengine/readme.md index fb88e8fd..08304ec7 100644 --- a/pipeline/fiftyone_pipeline_cloudrequestengine/readme.md +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/readme.md @@ -168,6 +168,14 @@ client script's complete handlers run later than they otherwise would, by the time the tests take and one more request. A page can read the first response's properties sooner through its change handlers. +The `browserderived` element's JavaScript properties are the browser +tests. The client script your server serves runs them once a +`BrowserDerivedCloud` engine +(`fiftyone_pipeline_cloudrequestengine.browserderived`) follows the +`CloudRequestEngine` in the pipeline. The device detection cloud pipeline +builders add that engine for you. If you build the pipeline another way, +add it there yourself. + Where a page sets a Content Security Policy, it must allow these for the browser tests to run. Otherwise HumanConfidenceSource stays `Passive`. diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/browserderived.py b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/browserderived.py new file mode 100644 index 00000000..9c485af2 --- /dev/null +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/browserderived.py @@ -0,0 +1,46 @@ +# ********************************************************************* +# This Original Work is copyright of 51 Degrees Mobile Experts Limited. +# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, +# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. +# +# This Original Work is licensed under the European Union Public Licence +# (EUPL) v.1.2 and is subject to its terms as set out below. +# +# If a copy of the EUPL was not distributed with this file, You can obtain +# one at https://opensource.org/licenses/EUPL-1.2. +# +# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be +# amended by the European Commission) shall be deemed incompatible for +# the purposes of the Work and the provisions of the compatibility +# clause in Article 5 of the EUPL shall not apply. +# +# If using the Work as, or as part of, a network application, by +# including the attribution notice(s) required under Article 5 of the EUPL +# in the end user terms of the application under an appropriate heading, +# such notice(s) shall fulfill the requirements of that article. +# ********************************************************************* + +from .cloudengine import CloudEngine + + +class BrowserDerivedCloud(CloudEngine): + + """! + Cloud engine for the "browserderived" section of the cloud response, + whose properties are available as flowdata.browserderived. + + The section is read as every cloud engine reads its own, and each + property takes its type from the Cloud Request Engine's accessible + properties. Properties whose metadata gives the JavaScript type are + the browser tests that come with HumanConfidence. The JSON bundler + lists those and the client script runs them. The cloud service can + return any number of them under any names, and none is written here. + + A key without the browserderived product logs no warning, because the + browser tests only come with a request that names HumanConfidence. + """ + + def __init__(self): + super(BrowserDerivedCloud, self).__init__() + self.datakey = "browserderived" + self.warns_on_missing_product = False diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudengine.py b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudengine.py index 7a4579a6..b95177da 100644 --- a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudengine.py +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudengine.py @@ -91,6 +91,10 @@ def __init__(self): # Whether set_cache has logged that this engine ignores a cache. self._cache_ignored_logged = False + # Whether to log a key that carries no properties for this engine. + # Set it False in an engine whose product only comes with some + # requests. + self.warns_on_missing_product = True def get_evidence_key_filter(self): @@ -219,7 +223,8 @@ def _load_properties(self, log): # at all. That is not a configuration error, so the engine has # no properties and the missing product is logged here, once. if not self.datakey in carried: - log("warning", "The key in use does not include access to any properties under the engine with key " + self.datakey + " that was added to the pipeline. For more details on resource keys, see our explainer: https://51degrees.com/documentation/_services__cloud__resource_keys.html?utm_source=code&utm_medium=comment&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_cloudrequestengine-src-fiftyone_pipeline_cloudrequestengine-cloudengine.py&utm_term=engine-properties-not-accessible " + "Available engine data keys are: " + str([e for e in carried])) + if getattr(self, "warns_on_missing_product", True): + log("warning", "The key in use does not include access to any properties under the engine with key " + self.datakey + " that was added to the pipeline. For more details on resource keys, see our explainer: https://51degrees.com/documentation/_services__cloud__resource_keys.html?utm_source=code&utm_medium=comment&utm_campaign=51degrees-python&utm_content=fiftyone_pipeline_cloudrequestengine-src-fiftyone_pipeline_cloudrequestengine-cloudengine.py&utm_term=engine-properties-not-accessible " + "Available engine data keys are: " + str([e for e in carried])) self.properties = {} else: self.properties = carried[self.datakey] diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudrequestengine.py b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudrequestengine.py index fdb61810..c262b6ca 100644 --- a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudrequestengine.py +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/cloudrequestengine.py @@ -85,6 +85,60 @@ def _properties(answer, data_key, name): yield value +def _browser_tests(answer, accessible): + + """! + The value of every browserderived Property in a response that may be a + JavaScript Property, told the way the .NET package tells one. A + Property counts in any of three cases: + + - the response's javascriptProperties lists it as browserderived and + its name joined by a dot, compared in any case + - the accessible Properties give it the JavaScript type, also compared + in any case + - the accessible Properties give it no type at all + + A Property is left out only where they type it as something else and + the list does not have it, so the rule can only refuse to cache. The + members that give null reasons are not Properties. + + @type answer: dict + @param answer: the response's JSON, read as an object + @type accessible: dict + @param accessible: the accessible Properties by product data key, or + None while they are not known + """ + + listed = None + for key, value in answer.items(): + if str(key).lower() == Constants.JAVASCRIPT_PROPERTIES_MEMBER: + if isinstance(value, list): + listed = {str(entry).lower() for entry in value + if isinstance(entry, str)} + types = {} + for key, product in (accessible or {}).items(): + if str(key).lower() == Constants.BROWSER_TESTS_DATA_KEY \ + and isinstance(product, dict): + for name, meta in product.items(): + value_type = meta.get("type") if isinstance(meta, dict) \ + else None + if value_type: + types[str(name).lower()] = str(value_type).lower() + for key, section in answer.items(): + if str(key).lower() != Constants.BROWSER_TESTS_DATA_KEY \ + or not isinstance(section, dict): + continue + for member, value in section.items(): + name = str(member).lower() + if name.endswith("nullreason"): + continue + value_type = types.get(name) + if (listed is not None and + Constants.BROWSER_TESTS_DATA_KEY + "." + name in listed) \ + or value_type in (None, "javascript"): + yield value + + def _takes_timeout(client): """! @@ -1039,8 +1093,8 @@ def is_cacheable(self, data): - A sealed Human Confidence result, being a HumanConfidence under derived that humanconfidence.is_sealed_value finds sealed. HumanConfidenceSource plays no part. - - The browser tests' script, being a BrowserTestsJavaScript under - browserderived that is not blank. + - A browser test, being a JavaScript Property of browserderived + that is not blank, told as _browser_tests tells one. A request made for one visitor never reaches the cache, as process and bypasses_cache say. A response that cannot be read as a JSON @@ -1069,9 +1123,8 @@ def is_cacheable(self, data): Constants.HUMAN_CONFIDENCE_PROPERTY)): return False return all(humanconfidence.is_blank(value) - for value in _properties( - answer, Constants.BROWSER_TESTS_DATA_KEY, - Constants.BROWSER_TESTS_PROPERTY)) + for value in _browser_tests( + answer, self.known_flow_element_properties())) def report_properties_not_covered(self, result): diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/constants.py b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/constants.py index 01d2e1a0..4e408b68 100644 --- a/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/constants.py +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/src/fiftyone_pipeline_cloudrequestengine/constants.py @@ -162,13 +162,14 @@ class Constants: # The members of a response that hold a value made for one visitor, # compared in any case. See CloudRequestEngine.is_cacheable. A 51Did is - # a top-level member. HumanConfidence and the browser tests' script are - # properties under the data key of the element that gives them. + # a top-level member. HumanConfidence is a property under derived. The + # browser tests are the JavaScript Properties of browserderived, and + # the response's javascriptProperties member lists them. DID_MEMBER = "fodid" HUMAN_CONFIDENCE_DATA_KEY = "derived" HUMAN_CONFIDENCE_PROPERTY = "humanconfidence" BROWSER_TESTS_DATA_KEY = "browserderived" - BROWSER_TESTS_PROPERTY = "browsertestsjavascript" + JAVASCRIPT_PROPERTIES_MEMBER = "javascriptproperties" # Takes the place of the licence key in every message the engine # builds, and of the sealed result and the transaction in a message made diff --git a/pipeline/fiftyone_pipeline_cloudrequestengine/tests/classes/browser_tests_harness.js b/pipeline/fiftyone_pipeline_cloudrequestengine/tests/classes/browser_tests_harness.js new file mode 100644 index 00000000..eabcb04f --- /dev/null +++ b/pipeline/fiftyone_pipeline_cloudrequestengine/tests/classes/browser_tests_harness.js @@ -0,0 +1,129 @@ +// Runs a rendered client script in Node against a minimal stand in for a +// browser, and prints every request the script sends back to the server. +// +// Usage: node browser_tests_harness.js