@schukai/monster 4.137.5 → 4.137.7
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.
- package/package.json +1 -1
- package/source/components/form/context-error.mjs +1 -1
- package/source/components/form/login.mjs +1 -1
- package/source/components/form/sheet.mjs +83 -7
- package/source/components/layout/slider.mjs +146 -47
- package/source/types/version.mjs +1 -1
- package/test/cases/components/form/sheet.mjs +126 -0
- package/test/cases/components/layout/slider.mjs +165 -0
- package/test/cases/components/navigation/table-of-content.mjs +32 -21
- package/test/cases/dom/resource/data.mjs +15 -7
- package/test/cases/dom/resourcemanager.mjs +8 -4
- package/test/cases/monster.mjs +1 -1
- package/test/web/import.js +3 -6
- package/test/web/test.html +2 -2
- package/test/web/tests.js +14285 -15456
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as chai from "chai";
|
|
2
|
+
import { initJSDOM } from "../../../util/jsdom.mjs";
|
|
3
|
+
import { ResizeObserverMock } from "../../../util/resize-observer.mjs";
|
|
4
|
+
|
|
5
|
+
const expect = chai.expect;
|
|
6
|
+
|
|
7
|
+
describe("Slider", function () {
|
|
8
|
+
let Slider;
|
|
9
|
+
|
|
10
|
+
before(function (done) {
|
|
11
|
+
initJSDOM()
|
|
12
|
+
.then(() => {
|
|
13
|
+
import("../../../../source/components/layout/slider.mjs")
|
|
14
|
+
.then((m) => {
|
|
15
|
+
Slider = m.Slider;
|
|
16
|
+
done();
|
|
17
|
+
})
|
|
18
|
+
.catch((e) => done(e));
|
|
19
|
+
})
|
|
20
|
+
.catch((e) => done(e));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
document.getElementById("mocks").innerHTML = "";
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should register monster-slider", function () {
|
|
28
|
+
expect(document.createElement("monster-slider")).to.be.instanceof(Slider);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should coalesce resize updates and skip unchanged sizes", function () {
|
|
32
|
+
const OriginalResizeObserver = window.ResizeObserver;
|
|
33
|
+
const originalGlobalResizeObserver = globalThis.ResizeObserver;
|
|
34
|
+
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
|
35
|
+
const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
36
|
+
|
|
37
|
+
class TrackingResizeObserver extends ResizeObserverMock {
|
|
38
|
+
static instances = [];
|
|
39
|
+
|
|
40
|
+
constructor(callback) {
|
|
41
|
+
super(callback);
|
|
42
|
+
TrackingResizeObserver.instances.push(this);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const scheduledCallbacks = [];
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
window.ResizeObserver = TrackingResizeObserver;
|
|
50
|
+
globalThis.ResizeObserver = TrackingResizeObserver;
|
|
51
|
+
window.requestAnimationFrame = (callback) => {
|
|
52
|
+
scheduledCallbacks.push(callback);
|
|
53
|
+
return scheduledCallbacks.length;
|
|
54
|
+
};
|
|
55
|
+
window.cancelAnimationFrame = () => {};
|
|
56
|
+
globalThis.requestAnimationFrame = window.requestAnimationFrame;
|
|
57
|
+
|
|
58
|
+
const mocks = document.getElementById("mocks");
|
|
59
|
+
const slider = document.createElement("monster-slider");
|
|
60
|
+
slider.setOption("features.autoPlay", false);
|
|
61
|
+
slider.setOption("features.thumbnails", false);
|
|
62
|
+
mocks.appendChild(slider);
|
|
63
|
+
|
|
64
|
+
const sliderElement = slider.shadowRoot.querySelector(
|
|
65
|
+
"[data-monster-role='slider']",
|
|
66
|
+
);
|
|
67
|
+
const resizeObserver = TrackingResizeObserver.instances.find((observer) =>
|
|
68
|
+
observer.elements.includes(sliderElement),
|
|
69
|
+
);
|
|
70
|
+
expect(resizeObserver).to.exist;
|
|
71
|
+
|
|
72
|
+
let resizeEvents = 0;
|
|
73
|
+
slider.addEventListener("monster-slider-resized", () => {
|
|
74
|
+
resizeEvents += 1;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
resizeObserver.triggerResize([
|
|
78
|
+
{ contentRect: { width: 320, height: 120 } },
|
|
79
|
+
]);
|
|
80
|
+
resizeObserver.triggerResize([
|
|
81
|
+
{ contentRect: { width: 640, height: 120 } },
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
expect(scheduledCallbacks).to.have.length(1);
|
|
85
|
+
scheduledCallbacks.shift()();
|
|
86
|
+
expect(resizeEvents).to.equal(1);
|
|
87
|
+
|
|
88
|
+
resizeObserver.triggerResize([
|
|
89
|
+
{ contentRect: { width: 640, height: 120 } },
|
|
90
|
+
]);
|
|
91
|
+
expect(scheduledCallbacks).to.have.length(0);
|
|
92
|
+
expect(resizeEvents).to.equal(1);
|
|
93
|
+
} finally {
|
|
94
|
+
window.ResizeObserver = OriginalResizeObserver;
|
|
95
|
+
globalThis.ResizeObserver = originalGlobalResizeObserver;
|
|
96
|
+
window.requestAnimationFrame = originalRequestAnimationFrame;
|
|
97
|
+
globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should coalesce drag updates to the latest move per frame", function () {
|
|
102
|
+
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
|
103
|
+
const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
104
|
+
|
|
105
|
+
const scheduledCallbacks = [];
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
window.requestAnimationFrame = (callback) => {
|
|
109
|
+
scheduledCallbacks.push(callback);
|
|
110
|
+
return scheduledCallbacks.length;
|
|
111
|
+
};
|
|
112
|
+
window.cancelAnimationFrame = () => {};
|
|
113
|
+
globalThis.requestAnimationFrame = window.requestAnimationFrame;
|
|
114
|
+
|
|
115
|
+
const mocks = document.getElementById("mocks");
|
|
116
|
+
const slider = document.createElement("monster-slider");
|
|
117
|
+
slider.setOption("features.autoPlay", false);
|
|
118
|
+
mocks.appendChild(slider);
|
|
119
|
+
|
|
120
|
+
for (let i = 0; i < 3; i += 1) {
|
|
121
|
+
const slide = document.createElement("div");
|
|
122
|
+
Object.defineProperty(slide, "offsetWidth", {
|
|
123
|
+
configurable: true,
|
|
124
|
+
value: 100,
|
|
125
|
+
});
|
|
126
|
+
slide.textContent = `Slide ${i + 1}`;
|
|
127
|
+
slider.appendChild(slide);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const sliderElement = slider.shadowRoot.querySelector(
|
|
131
|
+
"[data-monster-role='slider']",
|
|
132
|
+
);
|
|
133
|
+
Object.defineProperty(sliderElement, "offsetWidth", {
|
|
134
|
+
configurable: true,
|
|
135
|
+
value: 300,
|
|
136
|
+
});
|
|
137
|
+
slider.moveTo(0);
|
|
138
|
+
|
|
139
|
+
const createMouseEvent = (type, pageX) => {
|
|
140
|
+
const event = new window.MouseEvent(type, {
|
|
141
|
+
bubbles: true,
|
|
142
|
+
clientX: pageX,
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(event, "pageX", {
|
|
145
|
+
configurable: true,
|
|
146
|
+
value: pageX,
|
|
147
|
+
});
|
|
148
|
+
return event;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
sliderElement.dispatchEvent(createMouseEvent("mousedown", 10));
|
|
152
|
+
document.body.dispatchEvent(createMouseEvent("mousemove", 20));
|
|
153
|
+
document.body.dispatchEvent(createMouseEvent("mousemove", 55));
|
|
154
|
+
|
|
155
|
+
expect(scheduledCallbacks).to.have.length(1);
|
|
156
|
+
scheduledCallbacks.shift()();
|
|
157
|
+
expect(sliderElement.style.transform).to.contain("45px");
|
|
158
|
+
|
|
159
|
+
document.body.dispatchEvent(createMouseEvent("mouseup", 55));
|
|
160
|
+
} finally {
|
|
161
|
+
window.requestAnimationFrame = originalRequestAnimationFrame;
|
|
162
|
+
globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -8,6 +8,29 @@ import { initJSDOM } from "../../../util/jsdom.mjs";
|
|
|
8
8
|
let expect = chai.expect;
|
|
9
9
|
chai.use(chaiDom);
|
|
10
10
|
|
|
11
|
+
function waitForCondition(check, { timeout = 4000, interval = 25 } = {}) {
|
|
12
|
+
const startedAt = Date.now();
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const tick = () => {
|
|
15
|
+
try {
|
|
16
|
+
if (check()) {
|
|
17
|
+
resolve();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (Date.now() - startedAt >= timeout) {
|
|
25
|
+
reject(new Error('condition timed out'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setTimeout(tick, interval);
|
|
29
|
+
};
|
|
30
|
+
tick();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
11
34
|
describe('TableOfContent', function () {
|
|
12
35
|
this.timeout(10000);
|
|
13
36
|
|
|
@@ -35,7 +58,7 @@ describe('TableOfContent', function () {
|
|
|
35
58
|
mocks.innerHTML = '';
|
|
36
59
|
});
|
|
37
60
|
|
|
38
|
-
it('should bind to the first actually scrollable parent', function (
|
|
61
|
+
it('should bind to the first actually scrollable parent', async function () {
|
|
39
62
|
const target = document.getElementById('target');
|
|
40
63
|
const outerScroller = document.createElement('div');
|
|
41
64
|
const innerWrapper = document.createElement('div');
|
|
@@ -91,25 +114,13 @@ describe('TableOfContent', function () {
|
|
|
91
114
|
outerScroller.appendChild(innerWrapper);
|
|
92
115
|
target.appendChild(outerScroller);
|
|
93
116
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
try {
|
|
104
|
-
expect(navigation.style.top).to.equal('170px');
|
|
105
|
-
done();
|
|
106
|
-
} catch (error) {
|
|
107
|
-
done(error);
|
|
108
|
-
}
|
|
109
|
-
}, 20);
|
|
110
|
-
} catch (error) {
|
|
111
|
-
done(error);
|
|
112
|
-
}
|
|
113
|
-
}, 30);
|
|
117
|
+
const navigation = tableOfContent.shadowRoot.querySelector('.navigation');
|
|
118
|
+
|
|
119
|
+
await waitForCondition(() => navigation.style.top === '50px');
|
|
120
|
+
|
|
121
|
+
outerScroller.scrollTop = 120;
|
|
122
|
+
outerScroller.dispatchEvent(new window.Event('scroll'));
|
|
123
|
+
|
|
124
|
+
await waitForCondition(() => navigation.style.top === '170px');
|
|
114
125
|
});
|
|
115
126
|
});
|
|
@@ -12,6 +12,9 @@ let expect = chai.expect;
|
|
|
12
12
|
|
|
13
13
|
chai.use(chaiDom);
|
|
14
14
|
|
|
15
|
+
const validDataURL = 'https://example.test/data.json';
|
|
16
|
+
const allowedOrigins = ['https://example.test'];
|
|
17
|
+
|
|
15
18
|
let html1 = `
|
|
16
19
|
|
|
17
20
|
`;
|
|
@@ -63,7 +66,8 @@ describe('Data', function () {
|
|
|
63
66
|
it('setEventTypes()', function (done) {
|
|
64
67
|
|
|
65
68
|
const data = new Data({
|
|
66
|
-
src:
|
|
69
|
+
src: validDataURL,
|
|
70
|
+
allowedOrigins
|
|
67
71
|
});
|
|
68
72
|
|
|
69
73
|
data.connect().available().then(() => {
|
|
@@ -74,24 +78,26 @@ describe('Data', function () {
|
|
|
74
78
|
|
|
75
79
|
it('rejects executable script types', function () {
|
|
76
80
|
|
|
81
|
+
const scriptCount = document.querySelectorAll('script').length;
|
|
77
82
|
const data = new Data({
|
|
78
83
|
src: new DataUrl('console.log(1);', 'text/javascript').toString(),
|
|
79
84
|
type: 'text/javascript'
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
expect(() => data.connect()).to.throw('unsupported data resource type');
|
|
83
|
-
expect(document.
|
|
88
|
+
expect(document.querySelectorAll('script')).to.have.length(scriptCount);
|
|
84
89
|
|
|
85
90
|
})
|
|
86
91
|
|
|
87
92
|
it('rejects remote origins by default', function () {
|
|
88
93
|
|
|
94
|
+
const scriptCount = document.querySelectorAll('script').length;
|
|
89
95
|
const data = new Data({
|
|
90
96
|
src: 'https://cdn.example/data.json'
|
|
91
97
|
});
|
|
92
98
|
|
|
93
99
|
expect(() => data.connect()).to.throw('data resource origin not allowed');
|
|
94
|
-
expect(document.
|
|
100
|
+
expect(document.querySelectorAll('script')).to.have.length(scriptCount);
|
|
95
101
|
|
|
96
102
|
})
|
|
97
103
|
|
|
@@ -117,8 +123,9 @@ describe('Data', function () {
|
|
|
117
123
|
};
|
|
118
124
|
|
|
119
125
|
const data = new Data({
|
|
120
|
-
src:
|
|
121
|
-
id: 'data-error'
|
|
126
|
+
src: validDataURL,
|
|
127
|
+
id: 'data-error',
|
|
128
|
+
allowedOrigins
|
|
122
129
|
});
|
|
123
130
|
|
|
124
131
|
data.connect();
|
|
@@ -141,13 +148,14 @@ describe('Data', function () {
|
|
|
141
148
|
describe('External Data', () => {
|
|
142
149
|
|
|
143
150
|
let id = new ID('data').toString();
|
|
144
|
-
let server, data, url = '/layzr.json';
|
|
151
|
+
let server, data, url = 'https://example.test/layzr.json';
|
|
145
152
|
|
|
146
153
|
beforeEach(() => {
|
|
147
154
|
|
|
148
155
|
data = new Data({
|
|
149
156
|
src: url,
|
|
150
|
-
id: id
|
|
157
|
+
id: id,
|
|
158
|
+
allowedOrigins
|
|
151
159
|
});
|
|
152
160
|
|
|
153
161
|
});
|
|
@@ -6,6 +6,10 @@ import {ResourceManager} from "../../../source/dom/resourcemanager.mjs";
|
|
|
6
6
|
import {cleanupDOMFromTesting, initMutationObserverForTesting} from "../../util/cleanupdom.mjs";
|
|
7
7
|
import {initJSDOM} from "../../util/jsdom.mjs";
|
|
8
8
|
|
|
9
|
+
const validDataURL = 'https://example.test/data.json';
|
|
10
|
+
const validExampleURL = 'https://example.test/example.json';
|
|
11
|
+
const allowedOrigins = ['https://example.test'];
|
|
12
|
+
|
|
9
13
|
describe('ResourceManager', function () {
|
|
10
14
|
|
|
11
15
|
let fetchReference, returnStatus;
|
|
@@ -70,7 +74,7 @@ describe('ResourceManager', function () {
|
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
it('add data should instance of ResourceManager', function () {
|
|
73
|
-
expect(manager.addData(
|
|
77
|
+
expect(manager.addData(validDataURL, {allowedOrigins})).to.be.instanceOf(ResourceManager);
|
|
74
78
|
});
|
|
75
79
|
|
|
76
80
|
describe('connect resources', function () {
|
|
@@ -83,7 +87,7 @@ describe('ResourceManager', function () {
|
|
|
83
87
|
});
|
|
84
88
|
|
|
85
89
|
it('add data and connect should instance of ResourceManager', function () {
|
|
86
|
-
expect(manager.addData(
|
|
90
|
+
expect(manager.addData(validDataURL, {allowedOrigins}).connect()).to.be.instanceOf(ResourceManager);
|
|
87
91
|
});
|
|
88
92
|
})
|
|
89
93
|
|
|
@@ -98,13 +102,13 @@ describe('ResourceManager', function () {
|
|
|
98
102
|
});
|
|
99
103
|
|
|
100
104
|
it('add data and check availability should should return Promise', function () {
|
|
101
|
-
expect(manager.addData(
|
|
105
|
+
expect(manager.addData(validDataURL, {allowedOrigins}).available()).to.be.instanceOf(Promise);
|
|
102
106
|
});
|
|
103
107
|
})
|
|
104
108
|
|
|
105
109
|
describe('check availability example.json', function () {
|
|
106
110
|
it('add data and check content', function (done) {
|
|
107
|
-
manager.addData(
|
|
111
|
+
manager.addData(validExampleURL, {allowedOrigins}).connect().available().then(r => {
|
|
108
112
|
expect(document.querySelector('html').outerHTML).contains('>{"a":"test"}</script></head>');
|
|
109
113
|
done();
|
|
110
114
|
}).catch(e => done(e));
|
package/test/cases/monster.mjs
CHANGED
package/test/web/import.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
/** this file was created automatically by the run-web-tests script */
|
|
2
2
|
import "./prepare.js";
|
|
3
|
-
import "../cases/components/layout/tabs.mjs";
|
|
4
3
|
import "../cases/components/layout/slit-panel.mjs";
|
|
5
4
|
import "../cases/components/layout/panel.mjs";
|
|
6
|
-
import "../cases/components/
|
|
5
|
+
import "../cases/components/layout/slider.mjs";
|
|
7
6
|
import "../cases/components/content/viewer.mjs";
|
|
8
7
|
import "../cases/components/content/image-editor.mjs";
|
|
9
8
|
import "../cases/components/form/buy-box.mjs";
|
|
10
9
|
import "../cases/components/form/message-state-button.mjs";
|
|
11
|
-
import "../cases/components/form/button-bar.mjs";
|
|
12
10
|
import "../cases/components/form/reload.mjs";
|
|
13
11
|
import "../cases/components/form/context-help.mjs";
|
|
14
12
|
import "../cases/components/form/state-button.mjs";
|
|
15
|
-
import "../cases/components/form/select.mjs";
|
|
16
13
|
import "../cases/components/form/login.mjs";
|
|
17
|
-
import "../cases/components/form/confirm-button.mjs";
|
|
18
14
|
import "../cases/components/form/context-error.mjs";
|
|
15
|
+
import "../cases/components/form/choice-cards.mjs";
|
|
19
16
|
import "../cases/components/form/form.mjs";
|
|
20
17
|
import "../cases/components/form/tree-select.mjs";
|
|
21
18
|
import "../cases/components/form/popper-button.mjs";
|
|
@@ -30,9 +27,9 @@ import "../cases/components/host/host.mjs";
|
|
|
30
27
|
import "../cases/components/host/overlay.mjs";
|
|
31
28
|
import "../cases/components/host/util.mjs";
|
|
32
29
|
import "../cases/components/host/details.mjs";
|
|
33
|
-
import "../cases/components/datatable/drag-scroll.mjs";
|
|
34
30
|
import "../cases/components/datatable/writeback-sanitizer.mjs";
|
|
35
31
|
import "../cases/components/datatable/pagination.mjs";
|
|
32
|
+
import "../cases/components/navigation/site-navigation.mjs";
|
|
36
33
|
import "../cases/text/formatter.mjs";
|
|
37
34
|
import "../cases/text/generate-range-comparison-expression.mjs";
|
|
38
35
|
import "../cases/text/util.mjs";
|
package/test/web/test.html
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
|
12
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 4.
|
|
13
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
|
12
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 4.137.5</h1>
|
|
13
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Mon May 25 15:45:10 CEST 2026</div>
|
|
14
14
|
</div>
|
|
15
15
|
<div id="mocha-errors"
|
|
16
16
|
style="color: red;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"></div>
|