diff --git a/src/framework/enhancement/js/ContextAwareness.js b/src/framework/enhancement/js/ContextAwareness.js index 7df62e5b46..8d1561adb3 100644 --- a/src/framework/enhancement/js/ContextAwareness.js +++ b/src/framework/enhancement/js/ContextAwareness.js @@ -212,9 +212,18 @@ var fluid_2_0_0 = fluid_2_0_0 || {}; return typeof(navigator) !== "undefined" && navigator.platform ? navigator.platform : undefined; }; + // Context awareness for the reported user agent name + + fluid.contextAware.browser.getUserAgent = function () { + return typeof(navigator) !== "undefined" && navigator.userAgent ? navigator.userAgent : undefined; + }; + fluid.contextAware.makeChecks({ "fluid.browser.platformName": { funcName: "fluid.contextAware.browser.getPlatformName" + }, + "fluid.browser.userAgent": { + funcName: "fluid.contextAware.browser.getUserAgent" } }); diff --git a/tests/component-tests/textToSpeech/js/TextToSpeechTests.js b/tests/component-tests/textToSpeech/js/TextToSpeechTests.js index 58569459e4..e6bc2920e3 100644 --- a/tests/component-tests/textToSpeech/js/TextToSpeechTests.js +++ b/tests/component-tests/textToSpeech/js/TextToSpeechTests.js @@ -258,14 +258,33 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.test.conditionalTestUtils.bypassTest, "Browser appears to support TTS", "Browser does not appear to support TTS"); }; + fluid.tests.textToSpeech.isChromeOnWindows = function () { + return fluid.contextAware.getCheckValue(fluid.rootComponent, "{fluid.browser.isChrome}") && fluid.contextAware.getCheckValue(fluid.rootComponent, "{fluid.browser.platform.isWindows}"); + }; + + // The following environments are currently consider to not support + // pause and resume: + // Linux (any browser) + // Chrome on Windows due to this bug: + // https://bugs.chromium.org/p/chromium/issues/detail?id=679043 + + fluid.tests.textToSpeech.isPauseResumeSupporting = function () { + return !fluid.tests.textToSpeech.isChromeOnWindows() || !fluid.test.conditionalTestUtils.isBrowserOnLinux; + }; + + // Makes check Chrome on Windows due to TTS pause/resume bug + fluid.contextAware.makeChecks({ + "fluid.tests.textToSpeech.isPauseResumeSupporting": "fluid.tests.textToSpeech.isPauseResumeSupporting" + }); + fluid.defaults("fluid.tests.textToSpeech.contextAwareTestRunner", { gradeNames: ["fluid.test.conditionalTestUtils.contextAwareTestRunner"], contextAwareness: { supportsPauseResume: { checks: { supportsPauseResume: { - contextValue: "{fluid.browser.platform.isLinux}", - equals: false, + contextValue: "{fluid.tests.textToSpeech.isPauseResumeSupporting}", + equals: true, gradeNames: ["fluid.tests.textToSpeech.supportsPauseResume"] } } diff --git a/tests/test-core/utils/js/ConditionalTestUtils.js b/tests/test-core/utils/js/ConditionalTestUtils.js index c1517816d5..cc610e98ed 100644 --- a/tests/test-core/utils/js/ConditionalTestUtils.js +++ b/tests/test-core/utils/js/ConditionalTestUtils.js @@ -103,10 +103,34 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt return fluid.test.conditionalTestUtils.contextValueContains("Windows", "{fluid.browser.platformName}"); }; + // Makes checks for browser platform fluid.contextAware.makeChecks({ "fluid.browser.platform.isLinux": "fluid.test.conditionalTestUtils.isBrowserOnLinux", "fluid.browser.platform.isMac": "fluid.test.conditionalTestUtils.isBrowserOnMac", "fluid.browser.platform.isWindows": "fluid.test.conditionalTestUtils.isBrowserOnWindows" }); + // Functions for web browser name reporting for makeChecks + + fluid.test.conditionalTestUtils.isChromeBrowser = function () { + return fluid.test.conditionalTestUtils.contextValueContains("Chrome", "{fluid.browser.userAgent}"); + }; + + // We have to check that the userAgent string contains Safari, but does not + // contain Chrome, because Chrome on Mac includes the string "Safari" + fluid.test.conditionalTestUtils.isSafariBrowser = function () { + return fluid.test.conditionalTestUtils.contextValueContains("Safari", "{fluid.browser.userAgent}") && !fluid.test.conditionalTestUtils.contextValueContains("Chrome", "{fluid.browser.userAgent}"); + }; + + fluid.test.conditionalTestUtils.isFirefoxBrowser = function () { + return fluid.test.conditionalTestUtils.contextValueContains("Firefox", "{fluid.browser.userAgent}"); + }; + + // Makes checks for browser name + fluid.contextAware.makeChecks({ + "fluid.browser.isChrome": "fluid.test.conditionalTestUtils.isChromeBrowser", + "fluid.browser.isSafari": "fluid.test.conditionalTestUtils.isSafariBrowser", + "fluid.browser.isFirefox": "fluid.test.conditionalTestUtils.isFirefoxBrowser" + }); + })();