@google/model-viewer
Version:
Easily display interactive 3D models on the web and in AR!
56 lines • 2.31 kB
JavaScript
/*
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ModelViewerElementBase from '../../model-viewer-base.js';
import { FocusVisiblePolyfillMixin } from '../../utilities/focus-visible.js';
import { assetPath, waitForEvent } from '../helpers.js';
import { BasicSpecTemplate } from '../templates.js';
const expect = chai.expect;
suite('ModelViewerElementBase with FocusVisiblePolyfillMixin', () => {
let nextId = 0;
let tagName;
let ModelViewerElement;
let element;
setup(() => {
tagName = `model-viewer-focus-visible-${nextId++}`;
ModelViewerElement = class extends FocusVisiblePolyfillMixin(ModelViewerElementBase) {
static get is() {
return tagName;
}
};
customElements.define(tagName, ModelViewerElement);
});
BasicSpecTemplate(() => ModelViewerElement, () => tagName);
suite('when polyfill is present', () => {
setup(async () => {
element = new ModelViewerElement();
element.tabIndex = 0;
element.src = assetPath('cube.gltf');
document.body.appendChild(element);
await waitForEvent(element, 'load');
});
teardown(() => {
if (element.parentNode != null) {
element.parentNode.removeChild(element);
}
});
test('typically does not show the focus ring when focused', async () => {
element.dispatchEvent(new CustomEvent('mousedown'));
element.focus();
expect(document.activeElement).to.be.equal(element);
expect(window.getComputedStyle(element).outlineStyle).to.be.equal('none');
});
});
});
//# sourceMappingURL=focus-visible-spec.js.map