@ui5/webcomponents-base 0.0.0-2c7615fe9 → 0.0.0-3236d56be

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.eslintignore +3 -2
  2. package/CHANGELOG.md +199 -0
  3. package/README.md +26 -2
  4. package/bundle.esm.js +3 -2
  5. package/dist/Boot.js +34 -18
  6. package/dist/CSP.js +59 -0
  7. package/dist/CustomElementsRegistry.js +60 -4
  8. package/dist/CustomElementsScope.js +20 -98
  9. package/dist/CustomElementsScopeUtils.js +108 -0
  10. package/dist/Device.js +20 -1
  11. package/dist/EventProvider.js +5 -2
  12. package/dist/FeaturesRegistry.js +4 -1
  13. package/dist/FontFace.js +7 -95
  14. package/dist/InitialConfiguration.js +11 -7
  15. package/dist/Keys.js +47 -0
  16. package/dist/ManagedStyles.js +83 -0
  17. package/dist/Render.js +3 -1
  18. package/dist/Runtimes.js +107 -0
  19. package/dist/StaticAreaItem.js +4 -10
  20. package/dist/SystemCSSVars.js +4 -25
  21. package/dist/UI5Element.js +31 -24
  22. package/dist/UI5ElementMetadata.js +17 -1
  23. package/dist/asset-registries/Icons.js +21 -14
  24. package/dist/asset-registries/Illustrations.js +10 -3
  25. package/dist/asset-registries/LocaleData.js +17 -3
  26. package/dist/assets-meta/IconCollectionsAlias.js +18 -0
  27. package/dist/config/Icons.js +52 -0
  28. package/dist/config/Theme.js +25 -0
  29. package/dist/css/BusyIndicator.css +76 -0
  30. package/dist/css/FontFace.css +75 -0
  31. package/dist/css/OverrideFontFace.css +32 -0
  32. package/dist/css/SystemCSSVars.css +17 -0
  33. package/dist/features/F6Navigation.js +108 -0
  34. package/dist/features/OpenUI5Enablement.js +119 -0
  35. package/dist/generated/AssetParameters.js +1 -1
  36. package/dist/generated/VersionInfo.js +10 -0
  37. package/dist/generated/css/BusyIndicator.css.js +5 -0
  38. package/dist/generated/css/FontFace.css.js +5 -0
  39. package/dist/generated/css/OverrideFontFace.css.js +5 -0
  40. package/dist/generated/css/SystemCSSVars.css.js +5 -0
  41. package/dist/i18nBundle.js +33 -2
  42. package/dist/renderer/LitRenderer.js +32 -12
  43. package/dist/renderer/directives/style-map.js +72 -0
  44. package/dist/renderer/executeTemplate.js +19 -2
  45. package/dist/resources/bundle.esm.js +14 -8
  46. package/dist/resources/bundle.esm.js.map +1 -1
  47. package/dist/sap/base/Log.js +2 -10
  48. package/dist/sap/base/assert.js +1 -5
  49. package/dist/sap/base/security/encodeCSS.js +14 -0
  50. package/dist/sap/base/security/encodeXML.js +23 -0
  51. package/dist/sap/base/strings/toHex.js +8 -0
  52. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +1 -1
  53. package/dist/test-resources/pages/i18n.html +1 -3
  54. package/dist/test-resources/specs/ConfigurationChange.spec.js +9 -9
  55. package/dist/test-resources/specs/ConfigurationScript.spec.js +24 -24
  56. package/dist/test-resources/specs/ConfigurationURL.spec.js +33 -33
  57. package/dist/test-resources/specs/CustomTheme.spec.js +7 -7
  58. package/dist/test-resources/specs/EventProvider.spec.js +63 -0
  59. package/dist/test-resources/specs/StaticArea.spec.js +35 -35
  60. package/dist/test-resources/specs/Theming.spec.js +11 -11
  61. package/dist/test-resources/specs/UI5ElementInvalidation.js +29 -29
  62. package/dist/test-resources/specs/UI5ElementLifecycle.js +11 -11
  63. package/dist/test-resources/specs/UI5ElementListenForChildPropChanges.spec.js +11 -11
  64. package/dist/test-resources/specs/UI5ElementMetadataExt.js +8 -8
  65. package/dist/test-resources/specs/UI5ElementPropertyValidation.js +6 -6
  66. package/dist/test-resources/specs/UI5ElementPropsAndAttrs.spec.js +36 -36
  67. package/dist/test-resources/specs/UI5ElementShadowDOM.js +9 -9
  68. package/dist/test-resources/specs/UI5ElementSlots.js +9 -9
  69. package/dist/theming/CustomStyle.js +23 -3
  70. package/dist/theming/applyTheme.js +11 -10
  71. package/dist/theming/getEffectiveLinksHrefs.js +27 -0
  72. package/dist/theming/getEffectiveStyle.js +9 -0
  73. package/dist/theming/getStylesString.js +4 -2
  74. package/dist/theming/getThemeDesignerTheme.js +25 -5
  75. package/dist/theming/preloadLinks.js +23 -0
  76. package/dist/updateShadowRoot.js +8 -4
  77. package/dist/util/FocusableElements.js +8 -6
  78. package/dist/util/InvisibleMessage.js +11 -9
  79. package/dist/util/TabbableElements.js +4 -0
  80. package/dist/util/createLinkInHead.js +19 -0
  81. package/dist/util/escapeRegex.js +10 -0
  82. package/dist/util/generateHighlightedMarkup.js +42 -0
  83. package/dist/util/getNormalizedTarget.js +16 -0
  84. package/dist/util/isNodeHidden.js +1 -1
  85. package/lib/generate-asset-parameters/index.js +8 -5
  86. package/lib/generate-styles/index.js +26 -0
  87. package/lib/generate-version-info/index.js +32 -0
  88. package/package-scripts.js +12 -16
  89. package/package.json +10 -12
  90. package/src/Boot.js +34 -18
  91. package/src/CSP.js +59 -0
  92. package/src/CustomElementsRegistry.js +60 -4
  93. package/src/CustomElementsScope.js +20 -98
  94. package/src/CustomElementsScopeUtils.js +108 -0
  95. package/src/Device.js +20 -1
  96. package/src/EventProvider.js +5 -2
  97. package/src/FeaturesRegistry.js +4 -1
  98. package/src/FontFace.js +7 -95
  99. package/src/InitialConfiguration.js +11 -7
  100. package/src/Keys.js +47 -0
  101. package/src/ManagedStyles.js +83 -0
  102. package/src/Render.js +3 -1
  103. package/src/Runtimes.js +107 -0
  104. package/src/StaticAreaItem.js +4 -10
  105. package/src/SystemCSSVars.js +4 -25
  106. package/src/UI5Element.js +31 -24
  107. package/src/UI5ElementMetadata.js +17 -1
  108. package/src/asset-registries/Icons.js +21 -14
  109. package/src/asset-registries/Illustrations.js +10 -3
  110. package/src/asset-registries/LocaleData.js +17 -3
  111. package/src/assets-meta/IconCollectionsAlias.js +18 -0
  112. package/src/config/Icons.js +52 -0
  113. package/src/config/Theme.js +25 -0
  114. package/src/css/BusyIndicator.css +76 -0
  115. package/src/css/FontFace.css +75 -0
  116. package/src/css/OverrideFontFace.css +32 -0
  117. package/src/css/SystemCSSVars.css +17 -0
  118. package/src/features/F6Navigation.js +108 -0
  119. package/src/features/OpenUI5Enablement.js +119 -0
  120. package/src/i18nBundle.js +33 -2
  121. package/src/renderer/LitRenderer.js +32 -12
  122. package/src/renderer/directives/style-map.js +72 -0
  123. package/src/renderer/executeTemplate.js +19 -2
  124. package/src/theming/CustomStyle.js +23 -3
  125. package/src/theming/applyTheme.js +11 -10
  126. package/src/theming/getEffectiveLinksHrefs.js +27 -0
  127. package/src/theming/getEffectiveStyle.js +9 -0
  128. package/src/theming/getStylesString.js +4 -2
  129. package/src/theming/getThemeDesignerTheme.js +25 -5
  130. package/src/theming/preloadLinks.js +23 -0
  131. package/src/updateShadowRoot.js +8 -4
  132. package/src/util/FocusableElements.js +8 -6
  133. package/src/util/InvisibleMessage.js +11 -9
  134. package/src/util/TabbableElements.js +4 -0
  135. package/src/util/createLinkInHead.js +19 -0
  136. package/src/util/escapeRegex.js +10 -0
  137. package/src/util/generateHighlightedMarkup.js +42 -0
  138. package/src/util/getNormalizedTarget.js +16 -0
  139. package/src/util/isNodeHidden.js +1 -1
  140. package/used-modules.txt +4 -1
  141. package/dist/config/AssetsPath.js +0 -17
  142. package/dist/theming/createThemePropertiesStyleTag.js +0 -20
  143. package/dist/util/encodeCSS.js +0 -24
  144. package/hash.txt +0 -1
  145. package/src/config/AssetsPath.js +0 -17
  146. package/src/theming/createThemePropertiesStyleTag.js +0 -20
  147. package/src/util/encodeCSS.js +0 -24
@@ -162,18 +162,10 @@ function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
162
162
  }
163
163
  break;
164
164
  case Log.Level.DEBUG:
165
- if (console.debug) {
166
- isDetailsError ? console.debug(logText, '\n', sDetails) : console.debug(logText);
167
- } else {
168
- isDetailsError ? console.log(logText, '\n', sDetails) : console.log(logText);
169
- }
165
+ isDetailsError ? console.debug(logText, '\n', sDetails) : console.debug(logText);
170
166
  break;
171
167
  case Log.Level.TRACE:
172
- if (console.trace) {
173
- isDetailsError ? console.trace(logText, '\n', sDetails) : console.trace(logText);
174
- } else {
175
- isDetailsError ? console.log(logText, '\n', sDetails) : console.log(logText);
176
- }
168
+ isDetailsError ? console.trace(logText, '\n', sDetails) : console.trace(logText);
177
169
  break;
178
170
  }
179
171
  if (console.info && oLogEntry.supportInfo) {
@@ -2,11 +2,7 @@ import Log from './Log.js';
2
2
  var fnAssert = function (bResult, vMessage) {
3
3
  if (!bResult) {
4
4
  var sMessage = typeof vMessage === 'function' ? vMessage() : vMessage;
5
- if (console && console.assert) {
6
- console.assert(bResult, sMessage);
7
- } else {
8
- Log.debug('[Assertions] ' + sMessage);
9
- }
5
+ console.assert(bResult, sMessage);
10
6
  }
11
7
  };
12
8
  export default fnAssert;
@@ -0,0 +1,14 @@
1
+ import toHex from '../strings/toHex.js';
2
+ var rCSS = /[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xff\u2028\u2029][0-9A-Fa-f]?/g;
3
+ var fnCSS = function (sChar) {
4
+ var iChar = sChar.charCodeAt(0);
5
+ if (sChar.length === 1) {
6
+ return '\\' + toHex(iChar);
7
+ } else {
8
+ return '\\' + toHex(iChar) + ' ' + sChar.substr(1);
9
+ }
10
+ };
11
+ var fnEncodeCSS = function (sString) {
12
+ return sString.replace(rCSS, fnCSS);
13
+ };
14
+ export default fnEncodeCSS;
@@ -0,0 +1,23 @@
1
+ import toHex from '../strings/toHex.js';
2
+ var rHtml = /[\x00-\x2b\x2f\x3a-\x40\x5b-\x5e\x60\x7b-\xff\u2028\u2029]/g, rHtmlReplace = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/, mHtmlLookup = {
3
+ '<': '&lt;',
4
+ '>': '&gt;',
5
+ '&': '&amp;',
6
+ '"': '&quot;'
7
+ };
8
+ var fnHtml = function (sChar) {
9
+ var sEncoded = mHtmlLookup[sChar];
10
+ if (!sEncoded) {
11
+ if (rHtmlReplace.test(sChar)) {
12
+ sEncoded = '&#xfffd;';
13
+ } else {
14
+ sEncoded = '&#x' + toHex(sChar.charCodeAt(0)) + ';';
15
+ }
16
+ mHtmlLookup[sChar] = sEncoded;
17
+ }
18
+ return sEncoded;
19
+ };
20
+ var fnEncodeXML = function (sString) {
21
+ return sString.replace(rHtml, fnHtml);
22
+ };
23
+ export default fnEncodeXML;
@@ -0,0 +1,8 @@
1
+ var fnToHex = function (iChar, iLength) {
2
+ var sHex = iChar.toString(16);
3
+ if (iLength) {
4
+ sHex = sHex.padStart(iLength, "0");
5
+ }
6
+ return sHex;
7
+ };
8
+ export default fnToHex;
@@ -1989,7 +1989,7 @@ if (typeof window !== 'undefined') {
1989
1989
  }
1990
1990
  /*!
1991
1991
  * OpenUI5
1992
- * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
1992
+ * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
1993
1993
  * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
1994
1994
  */
1995
1995
  // Based on coding from the HTML4 Sanitizer by Google Inc.
@@ -17,9 +17,7 @@
17
17
  const demo = async () => {
18
18
  ["de", "es", "fr", "en"].forEach(localeId => registerI18nLoader("myApp", localeId, () => `./assets/messagebundle_${localeId}.properties`));
19
19
 
20
- await fetchI18nBundle("myApp");
21
-
22
- const bundle = getI18nBundle("myApp");
20
+ const bundle = await getI18nBundle("myApp");
23
21
 
24
22
  const pleaseWait = bundle.getText("PLEASE_WAIT");
25
23
  console.log("Please wait in the current language is: ", pleaseWait);
@@ -1,27 +1,27 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Some configuration options can be changed at runtime", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/Configuration.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html");
6
6
  });
7
7
 
8
- it("Tests that theme can be changed", () => {
8
+ it("Tests that theme can be changed", async () => {
9
9
  const newTheme = 'sap_belize_hcb';
10
10
 
11
- const res = browser.executeAsync( async (newTheme, done) => {
11
+ const res = await browser.executeAsync( async (newTheme, done) => {
12
12
  const config = window['sap-ui-webcomponents-bundle'].configuration;
13
13
  await config.setTheme(newTheme);
14
- return done(config.getTheme());
14
+ done(config.getTheme());
15
15
  }, newTheme);
16
16
  assert.strictEqual(res, newTheme, "Theme changed to HCB");
17
17
  });
18
18
 
19
- it("Tests that noConflict can be changed", () => {
20
- const res = browser.execute( () => {
19
+ it("Tests that noConflict can be changed", async () => {
20
+ const res = await browser.executeAsync(done => {
21
21
  const config = window['sap-ui-webcomponents-bundle'].configuration;
22
22
  config.setNoConflict({events: ["selection-change"]});
23
- return config.getNoConflict();
23
+ done(config.getNoConflict());
24
24
  });
25
- assert.strictEqual(res.events.includes("selection-change"), true, "selection-change was successfully registered as a no conflict event");
25
+ assert.include(res.events, "selection-change", "selection-change was successfully registered as a no conflict event");
26
26
  });
27
27
  });
@@ -1,62 +1,62 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Configuration script has effect", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/ConfigurationScript.html?do-not-change-configuration");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/ConfigurationScript.html?do-not-change-configuration");
6
6
  });
7
7
 
8
- it("Tests that RTL is applied", () => {
9
- const res = browser.execute( () => {
8
+ it("Tests that RTL is applied", async () => {
9
+ const res = await browser.executeAsync(done => {
10
10
  const config = window['sap-ui-webcomponents-bundle'].configuration;
11
- return config.getRTL();
11
+ done(config.getRTL());
12
12
  });
13
13
  assert.strictEqual(res, true, "RTL is true");
14
14
  });
15
15
 
16
- it("Tests that language is applied", () => {
17
- const res = browser.execute( () => {
16
+ it("Tests that language is applied", async () => {
17
+ const res = await browser.executeAsync(done => {
18
18
  const config = window['sap-ui-webcomponents-bundle'].configuration;
19
- return config.getLanguage();
19
+ done(config.getLanguage());
20
20
  });
21
21
  assert.strictEqual(res, 'ja', "language is japanese");
22
22
  });
23
23
 
24
- it("Tests that calendarType is applied", () => {
25
- const res = browser.execute( () => {
24
+ it("Tests that calendarType is applied", async () => {
25
+ const res = await browser.executeAsync(done => {
26
26
  const config = window['sap-ui-webcomponents-bundle'].configuration;
27
- return config.getCalendarType();
27
+ done(config.getCalendarType());
28
28
  });
29
29
  assert.strictEqual(res, 'Japanese', "calendarType is japanese");
30
30
  });
31
31
 
32
- it("Tests that formatSettings are applied", () => {
33
- const res = browser.execute( () => {
32
+ it("Tests that formatSettings are applied", async () => {
33
+ const res = await browser.executeAsync(done => {
34
34
  const config = window['sap-ui-webcomponents-bundle'].configuration;
35
- return config.getFirstDayOfWeek();
35
+ done(config.getFirstDayOfWeek());
36
36
  });
37
37
  assert.strictEqual(res, 0, "First day of week is applied");
38
38
  });
39
39
 
40
- it("Tests that theme is applied", () => {
41
- const res = browser.execute( () => {
40
+ it("Tests that theme is applied", async () => {
41
+ const res = await browser.executeAsync(done => {
42
42
  const config = window['sap-ui-webcomponents-bundle'].configuration;
43
- return config.getTheme();
43
+ done(config.getTheme());
44
44
  });
45
45
  assert.strictEqual(res, 'sap_belize_hcb', "Thems is HCB");
46
46
  });
47
47
 
48
- it("Tests that noConflict is applied", () => {
49
- const res = browser.execute( () => {
48
+ it("Tests that noConflict is applied", async () => {
49
+ const res = await browser.executeAsync(done => {
50
50
  const config = window['sap-ui-webcomponents-bundle'].configuration;
51
- return config.getNoConflict();
51
+ done(config.getNoConflict());
52
52
  });
53
- assert.strictEqual(res.events.includes("selection-change"), true, "selectionChange was successfully registered as a no conflict event");
53
+ assert.include(res.events, "selection-change", "selectionChange was successfully registered as a no conflict event");
54
54
  });
55
55
 
56
- it("Tests that animationMode is applied", () => {
57
- const res = browser.execute( () => {
56
+ it("Tests that animationMode is applied", async () => {
57
+ const res = await browser.executeAsync(done => {
58
58
  const config = window['sap-ui-webcomponents-bundle'].configuration;
59
- return config.getAnimationMode();
59
+ done(config.getAnimationMode());
60
60
  });
61
61
  assert.strictEqual(res, 'basic', "animationMode is basic");
62
62
  });
@@ -1,46 +1,46 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Some settings can be set via SAP UI URL params", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-ui-rtl=true&sap-ui-language=ja&sap-ui-calendarType=Japanese&sap-ui-theme=sap_belize_hcb&sap-ui-animationMode=basic");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-ui-rtl=true&sap-ui-language=ja&sap-ui-calendarType=Japanese&sap-ui-theme=sap_belize_hcb&sap-ui-animationMode=basic");
6
6
  });
7
7
 
8
- it("Tests that RTL is applied", () => {
9
- const res = browser.execute( () => {
8
+ it("Tests that RTL is applied", async () => {
9
+ const res = await browser.executeAsync(done => {
10
10
  const config = window['sap-ui-webcomponents-bundle'].configuration;
11
- return config.getRTL();
11
+ done(config.getRTL());
12
12
  });
13
13
  assert.strictEqual(res, true, "RTL is true");
14
14
  });
15
15
 
16
- it("Tests that language is applied", () => {
17
- const res = browser.execute( () => {
16
+ it("Tests that language is applied", async () => {
17
+ const res = await browser.executeAsync(done => {
18
18
  const config = window['sap-ui-webcomponents-bundle'].configuration;
19
- return config.getLanguage();
19
+ done(config.getLanguage());
20
20
  });
21
21
  assert.strictEqual(res, 'ja', "language is japanese");
22
22
  });
23
23
 
24
- it("Tests that calendarType is applied", () => {
25
- const res = browser.execute( () => {
24
+ it("Tests that calendarType is applied", async () => {
25
+ const res = await browser.executeAsync(done => {
26
26
  const config = window['sap-ui-webcomponents-bundle'].configuration;
27
- return config.getCalendarType();
27
+ done(config.getCalendarType());
28
28
  });
29
29
  assert.strictEqual(res, 'Japanese', "calendarType is japanese");
30
30
  });
31
31
 
32
- it("Tests that theme is applied", () => {
33
- const res = browser.execute( () => {
32
+ it("Tests that theme is applied", async () => {
33
+ const res = await browser.executeAsync(done => {
34
34
  const config = window['sap-ui-webcomponents-bundle'].configuration;
35
- return config.getTheme();
35
+ done(config.getTheme());
36
36
  });
37
37
  assert.strictEqual(res, 'sap_belize_hcb', "Thems is HCB");
38
38
  });
39
39
 
40
- it("Tests that animationMode is applied", () => {
41
- const res = browser.execute( () => {
40
+ it("Tests that animationMode is applied", async () => {
41
+ const res = await browser.executeAsync(done => {
42
42
  const config = window['sap-ui-webcomponents-bundle'].configuration;
43
- return config.getAnimationMode();
43
+ done(config.getAnimationMode());
44
44
  });
45
45
  assert.strictEqual(res, 'basic', "animationMode is basic");
46
46
  });
@@ -48,22 +48,22 @@ describe("Some settings can be set via SAP UI URL params", () => {
48
48
 
49
49
 
50
50
  describe("Some settings can be set via SAP URL params", () => {
51
- before(() => {
52
- browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-language=bg&sap-theme=sap_fiori_3_dark");
51
+ before(async () => {
52
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-language=bg&sap-theme=sap_fiori_3_dark");
53
53
  });
54
54
 
55
- it("Tests that language is applied", () => {
56
- const res = browser.execute( () => {
55
+ it("Tests that language is applied", async () => {
56
+ const res = await browser.executeAsync(done => {
57
57
  const config = window['sap-ui-webcomponents-bundle'].configuration;
58
- return config.getLanguage();
58
+ done(config.getLanguage());
59
59
  });
60
60
  assert.strictEqual(res, 'bg', "language is bulgarian");
61
61
  });
62
62
 
63
- it("Tests that theme is applied", () => {
64
- const res = browser.execute( () => {
63
+ it("Tests that theme is applied", async () => {
64
+ const res = await browser.executeAsync(done => {
65
65
  const config = window['sap-ui-webcomponents-bundle'].configuration;
66
- return config.getTheme();
66
+ done(config.getTheme());
67
67
  });
68
68
  assert.strictEqual(res, 'sap_fiori_3_dark', "Thems is Fiori Dark");
69
69
  });
@@ -71,22 +71,22 @@ describe("Some settings can be set via SAP URL params", () => {
71
71
 
72
72
 
73
73
  describe("SAP UI params take precedence over the SAP params", () => {
74
- before(() => {
75
- browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-language=bg&sap-ui-language=de&sap-theme=sap_fiori_3_dark&sap-theme=sap_fiori_3_hcb");
74
+ before(async () => {
75
+ await browser.url("http://localhost:9191/test-resources/pages/Configuration.html?sap-language=bg&sap-ui-language=de&sap-theme=sap_fiori_3_dark&sap-theme=sap_fiori_3_hcb");
76
76
  });
77
77
 
78
- it("Tests that language is applied via sap-ui-language", () => {
79
- const res = browser.execute( () => {
78
+ it("Tests that language is applied via sap-ui-language", async () => {
79
+ const res = await browser.executeAsync(done => {
80
80
  const config = window['sap-ui-webcomponents-bundle'].configuration;
81
- return config.getLanguage();
81
+ done(config.getLanguage());
82
82
  });
83
83
  assert.strictEqual(res, 'de', "language is german");
84
84
  });
85
85
 
86
- it("Tests that theme is applied via sap-ui-theme", () => {
87
- const res = browser.execute( () => {
86
+ it("Tests that theme is applied via sap-ui-theme", async () => {
87
+ const res = await browser.executeAsync(done => {
88
88
  const config = window['sap-ui-webcomponents-bundle'].configuration;
89
- return config.getTheme();
89
+ done(config.getTheme());
90
90
  });
91
91
  assert.strictEqual(res, 'sap_fiori_3_hcb', "Thems is Fiori HCB");
92
92
  });
@@ -1,14 +1,14 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Custom themes can be registered", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
6
  });
7
7
 
8
- it("Tests that theme parameters are changed on theme change", () => {
8
+ it("Tests that theme parameters are changed on theme change", async () => {
9
9
  const newTheme = 'my_custom_theme';
10
10
 
11
- const res = browser.executeAsync( async (newTheme, done) => {
11
+ const res = await browser.executeAsync( async (newTheme, done) => {
12
12
  const var1 = "--var1: #555555";
13
13
 
14
14
  window.registerThemePropertiesLoader("@ui5/webcomponents-base-test", newTheme, () => `:root{ ${var1}; }`);
@@ -16,9 +16,9 @@ describe("Custom themes can be registered", () => {
16
16
  const config = window['sap-ui-webcomponents-bundle'].configuration;
17
17
  await config.setTheme(newTheme);
18
18
 
19
- const style = document.querySelector(`style[data-ui5-theme-properties="@ui5/webcomponents-base-test"]`);
20
- const varsFound = style && style.textContent.includes(var1);
21
- return done(varsFound);
19
+ const style = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === "data-ui5-theme-properties|@ui5/webcomponents-base-test").cssRules[0].cssText;
20
+ const varsFound = style && style.includes(var1);
21
+ done(varsFound);
22
22
  }, newTheme);
23
23
 
24
24
  assert.strictEqual(res, true, "Theme parameters changed");
@@ -0,0 +1,63 @@
1
+ const assert = require("chai").assert;
2
+
3
+ describe("Event provider attaches and detaches listeners properly", () => {
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
+ });
7
+
8
+ it("Tests that listeners can be removed (1 listener)", async () => {
9
+
10
+ const res = await browser.executeAsync(done => {
11
+ let timesCalled = 0;
12
+ const ep = new window["sap-ui-webcomponents-bundle"].EventProvider();
13
+ const callback = () => {
14
+ timesCalled++;
15
+ };
16
+
17
+ // Setup
18
+ ep.attachEvent("test", callback);
19
+
20
+ // Act
21
+ ep.fireEvent("test"); // should execute the callback and increase the counter
22
+
23
+ // Setup
24
+ ep.detachEvent("test", callback);
25
+
26
+ // Act
27
+ ep.fireEvent("test"); // should not execute the callback and increase the counter
28
+
29
+ done(timesCalled);
30
+ });
31
+
32
+ assert.strictEqual(res, 1, "The callback should be called exactly once");
33
+ });
34
+
35
+ it("Tests that listeners can be removed (more than 1 listener)", async () => {
36
+
37
+ const res = await browser.executeAsync(done => {
38
+ let timesCalled = 0;
39
+ const ep = new window["sap-ui-webcomponents-bundle"].EventProvider();
40
+ const callback = () => {
41
+ timesCalled++;
42
+ };
43
+ const somePreviousCallback = () => {};
44
+
45
+ // Setup
46
+ ep.attachEvent("test", somePreviousCallback); // Attach something so that after detachEvent the listeners array is not empty!
47
+ ep.attachEvent("test", callback);
48
+
49
+ // Act
50
+ ep.fireEvent("test"); // should execute the callback and increase the counter
51
+
52
+ // Setup
53
+ ep.detachEvent("test", callback);
54
+
55
+ // Act
56
+ ep.fireEvent("test"); // should not execute the callback and increase the counter
57
+
58
+ done(timesCalled);
59
+ });
60
+
61
+ assert.strictEqual(res, 1, "The callback should be called exactly once");
62
+ });
63
+ });
@@ -1,26 +1,26 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Some configuration options can be changed at runtime", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
6
  });
7
7
 
8
- it("Tests control with no static area item", () => {
9
- const componentId = browser.$("#no-static-area").getProperty("_id");
10
- const staticArea = browser.$("ui5-static-area");
8
+ it("Tests control with no static area item", async () => {
9
+ const componentId = await browser.$("#no-static-area").getProperty("_id");
10
+ const staticArea = await browser.$("ui5-static-area");
11
11
 
12
- assert.notOk(staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
12
+ assert.notOk(await staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
13
13
  });
14
14
 
15
- it("Tests control with static area item", () => {
16
- const componentId = browser.$("#with-static-area").getProperty("_id");
17
- const staticArea = browser.$("ui5-static-area");
15
+ it("Tests control with static area item", async () => {
16
+ const componentId = await browser.$("#with-static-area").getProperty("_id");
17
+ const staticArea = await browser.$("ui5-static-area");
18
18
 
19
- assert.ok(staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
19
+ assert.ok(await staticArea.$(`.${componentId}`).isExisting(), "No static area item is defined for this control");
20
20
  });
21
21
 
22
- it("Tests removing an element with static area", () => {
23
- const result = browser.execute(() => {
22
+ it("Tests removing an element with static area", async () => {
23
+ const result = await browser.executeAsync(done => {
24
24
  let res = true;
25
25
  window.onerror = (errorMsg, url, lineNumber) => {
26
26
  res = false;
@@ -28,51 +28,51 @@ describe("Some configuration options can be changed at runtime", () => {
28
28
 
29
29
  document.querySelector("#no-static-area").remove();
30
30
 
31
- return res;
31
+ done(res);
32
32
  });
33
33
 
34
34
  assert.ok(result, "Static area removed from DOM successfully");
35
35
  });
36
36
 
37
- it("Test RTL not set for static area items", () => {
38
- const componentId = browser.$("#with-static-area").getProperty("_id");
39
- const staticArea = browser.$("ui5-static-area");
37
+ it("Test RTL not set for static area items", async () => {
38
+ const componentId = await browser.$("#with-static-area").getProperty("_id");
39
+ const staticArea = await browser.$("ui5-static-area");
40
40
 
41
- assert.notOk(staticArea.$(`.${componentId}`).getAttribute("dir"), "dir attribute not set for static area item");
41
+ assert.notOk(await staticArea.$(`.${componentId}`).getAttribute("dir"), "dir attribute not set for static area item");
42
42
  });
43
43
 
44
- it("Test RTL set for static area items", () => {
45
- const componentId = browser.$("#with-static-area-rtl").getProperty("_id");
46
- const staticArea = browser.$("ui5-static-area");
44
+ it("Test RTL set for static area items", async () => {
45
+ const componentId = await browser.$("#with-static-area-rtl").getProperty("_id");
46
+ const staticArea = await browser.$("ui5-static-area");
47
47
 
48
- assert.equal(staticArea.$(`.${componentId}`).getAttribute("dir"), "rtl", "dir property correctly set for static area item");
48
+ assert.equal(await staticArea.$(`.${componentId}`).getAttribute("dir"), "rtl", "dir property correctly set for static area item");
49
49
  });
50
50
 
51
- it("Test setting RTL for a static area item owner", () => {
52
- const componentId = browser.$("#with-static-area").getProperty("_id");
53
- const staticArea = browser.$("ui5-static-area");
51
+ it("Test setting RTL for a static area item owner", async () => {
52
+ const componentId = await browser.$("#with-static-area").getProperty("_id");
53
+ const staticArea = await browser.$("ui5-static-area");
54
54
 
55
- browser.$("#with-static-area").setAttribute("dir", "rtl");
56
- browser.executeAsync( async (done) => {
55
+ await browser.$("#with-static-area").setAttribute("dir", "rtl");
56
+ await browser.executeAsync( async (done) => {
57
57
  await window["sap-ui-webcomponents-bundle"].applyDirection();
58
58
  await window["sap-ui-webcomponents-bundle"].renderFinished();
59
59
 
60
- return done();
60
+ done();
61
61
  });
62
- assert.equal(staticArea.$(`.${componentId}`).getAttribute("dir"), "rtl", "dir attribute dynamically set for static area item owner");
62
+ assert.equal(await staticArea.$(`.${componentId}`).getAttribute("dir"), "rtl", "dir attribute dynamically set for static area item owner");
63
63
  });
64
64
 
65
- it("Test removing RTL for a static area item owner", () => {
66
- const componentId = browser.$("#with-static-area-rtl").getProperty("_id");
67
- const staticArea = browser.$("ui5-static-area");
65
+ it("Test removing RTL for a static area item owner", async () => {
66
+ const componentId = await browser.$("#with-static-area-rtl").getProperty("_id");
67
+ const staticArea = await browser.$("ui5-static-area");
68
68
 
69
- browser.$("#with-static-area-rtl-container").removeAttribute("dir");
70
- browser.executeAsync( async (done) => {
69
+ await browser.$("#with-static-area-rtl-container").removeAttribute("dir");
70
+ await browser.executeAsync( async (done) => {
71
71
  await window["sap-ui-webcomponents-bundle"].applyDirection();
72
72
  await window["sap-ui-webcomponents-bundle"].renderFinished();
73
73
 
74
- return done();
74
+ done();
75
75
  });
76
- assert.notOk(staticArea.$(`.${componentId}`).getAttribute("dir"), "dir attribute dynamically removed for static area item owner");
76
+ assert.notOk(await staticArea.$(`.${componentId}`).getAttribute("dir"), "dir attribute dynamically removed for static area item owner");
77
77
  });
78
78
  });
@@ -1,30 +1,30 @@
1
1
  const assert = require("chai").assert;
2
2
 
3
3
  describe("Theming works", () => {
4
- before(() => {
5
- browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
4
+ before(async () => {
5
+ await browser.url("http://localhost:9191/test-resources/pages/AllTestElements.html");
6
6
  });
7
7
 
8
- it("Tests that the parameters for the default theme are embedded on boot", () => {
8
+ it("Tests that the parameters for the default theme are embedded on boot", async () => {
9
9
 
10
- const res = browser.execute(() => {
11
- const style = document.querySelector(`style[data-ui5-theme-properties="@ui5/webcomponents-base-test"]`);
12
- return style && style.textContent.includes("--var1: red"); // see test/assets/Themes.js
10
+ const res = await browser.executeAsync(done => {
11
+ const style = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === "data-ui5-theme-properties|@ui5/webcomponents-base-test").cssRules[0].cssText
12
+ done(style && style.includes("--var1: red")); // see test/assets/Themes.js
13
13
  });
14
14
 
15
15
  assert.strictEqual(res, true, "The fiori3 vars are found");
16
16
  });
17
17
 
18
- it("Tests that theme parameters are changed on theme change", () => {
18
+ it("Tests that theme parameters are changed on theme change", async () => {
19
19
  const newTheme = 'sap_belize_hcb';
20
20
 
21
- const res = browser.executeAsync( async (newTheme, done) => {
21
+ const res = await browser.executeAsync( async (newTheme, done) => {
22
22
  const config = window['sap-ui-webcomponents-bundle'].configuration;
23
23
  await config.setTheme(newTheme);
24
24
 
25
- const style = document.querySelector(`style[data-ui5-theme-properties="@ui5/webcomponents-base-test"]`);
26
- const varsFound = style && style.textContent.includes("--var1: orange"); // see test/assets/Themes.js
27
- return done(varsFound);
25
+ const style = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === "data-ui5-theme-properties|@ui5/webcomponents-base-test").cssRules[0].cssText
26
+ const varsFound = style && style.includes("--var1: orange"); // see test/assets/Themes.js
27
+ done(varsFound);
28
28
  }, newTheme);
29
29
 
30
30
  assert.strictEqual(res, true, "Theme parameters changed");