How to use el1.getAttribute method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

resonance-audio_integration.test.js

Source:resonance-audio_integration.test.js Github

copy

Full Screen

1/* global2setup,3teardown,4suite,5test,6expect,7THREE,8HTMLElement,9HTMLMediaElement,10document */11const { ResonanceAudio } = require('resonance-audio')12const {13 sceneFactory,14 entityFactory,15 elementFactory,16 putOnPage,17 putOnPageAndWaitForLoad,18 compareMatrixtoPosAndRot,19 createMatrixFromResonanceSource20} = require('./helpers')21const cr = 'resonance-audio-room'22const crbb = 'resonance-audio-room-bb'23const cs = 'resonance-audio-src'24suite(`component ${cs} in a ${cr}`, () => {25 let asset26 let containerEl27 let roomEl28 let srcEl1, srcEl229 let roomComponent30 let component1, component231 setup(done => {32 // Create this structure:33 // ```html34 // <a-scene>35 // <a-assets>36 // <audio id="track" src="base/tests/assets/track.mp3" />37 // </a-assets>38 // <a-entity position="-1 -2 -3"> <!-- containerEl -->39 // <a-entity40 // resonance-audio-room="..."41 // position="3 3 3"> <!-- roomEl -->42 // <a-entity43 // resonance-audio-src="src:#track;..."44 // id="srcEl1"45 // position="1 1 1"46 // rotation="0 45 0"></a-entity> <!-- srcEl1 -->47 // <a-entity48 // resonance-audio-src="position:-1 -1 -1; rotation:0 -90 0;..."49 // id="srcEl2"></a-entity> <!-- srcEl2 -->50 // </a-entity>51 // </a-entity>52 // </a-scene>53 // ```54 // roomEl position: 2 1 055 // srcEl1 position: 3 2 156 // srcEl2 position: 2 1 057 // srcEl2 cposition: 1 0 -158 putOnPageAndWaitForLoad(59 sceneFactory([60 elementFactory('a-assets', {},61 elementFactory('audio', {62 id: 'track',63 src: 'base/tests/assets/track.mp3'64 })65 ),66 entityFactory({ position: '-1 -2 -3' },67 entityFactory({68 position: '3 3 3',69 [cr]: { visualize: true }70 }, [71 entityFactory({72 id: 'srcEl1',73 position: '1 1 1',74 rotation: '0 45 0',75 [cs]: {76 src: '#track',77 visualize: true,78 autoplay: true,79 gain: 1.1,80 minDistance: 0.5,81 maxDistance: 100,82 directivityPattern: { x: 0.5, y: 2 },83 sourceWidth: 20,84 rolloff: 'linear'85 }86 }),87 entityFactory({88 id: 'srcEl2',89 [cs]: {90 visualize: true,91 position: '-1 -1 -1',92 rotation: '0 -90 0'93 }94 })95 ])96 )97 ]),98 done99 )100 containerEl = document.querySelectorAll('a-entity')[0]101 roomEl = document.querySelector(`[${cr}]`)102 srcEl1 = document.querySelector('#srcEl1')103 srcEl2 = document.querySelector('#srcEl2')104 asset = document.querySelector('audio')105 asset.muted = true106 roomComponent = roomEl.components[cr]107 component1 = srcEl1.components[cs]108 component2 = srcEl2.components[cs]109 })110 suite(`${cs} initialization`, () => {111 test('playback', () => {112 // Src and room relation.113 expect(srcEl1.getAttribute(cs).src).to.equal(asset)114 expect(srcEl1.getAttribute(cs).room).to.equal('')115 expect(component1.sound).to.equal(asset)116 expect(component1.connected).to.deep.equal({ element: true, stream: false })117 expect(component1.room).to.equal(roomComponent)118 expect(component1.resonance).to.be.an.instanceof(ResonanceAudio.Source)119 expect(component1.room.el.sounds).to.be.an('array').and.include(asset)120 expect(component1.defaultAudioEl).to.be.instanceof(HTMLMediaElement)121 })122 test('position, orientation and visualization position and orientation', () => {123 document.querySelector('a-scene').object3D.updateMatrixWorld()124 // Audio source in world coordinates.125 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: 3, y: 2, z: 1 }, { x: 0, y: 45, z: 0 })126 compareMatrixtoPosAndRot(srcEl2.object3D.matrixWorld, { x: 2, y: 1, z: 0 }, { x: 0, y: 0, z: 0 })127 // Resonance Source in world coordinates.128 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: 3, y: 2, z: 1 }, { x: 0, y: 45, z: 0 })129 compareMatrixtoPosAndRot(component2.getMatrixWorld(), { x: 1, y: 0, z: -1 }, { x: 0, y: -90, z: 0 })130 // Resonance Source in room coordinates.131 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 1, y: 1, z: 1 }, { x: 0, y: 45, z: 0 })132 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component2.resonance), { x: -1, y: -1, z: -1 }, { x: 0, y: -90, z: 0 })133 // Visualization in world coordinates.134 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: 3, y: 2, z: 1 }, { x: 0, y: 45, z: 0 })135 compareMatrixtoPosAndRot(srcEl2.getObject3D('audio-src').matrixWorld, { x: 1, y: 0, z: -1 }, { x: 0, y: -90, z: 0 })136 })137 test('acoustic parameters', () => {138 expect(component1.resonance.input.gain.value).to.be.closeTo(1.1, 0.01)139 expect(component1.resonance._attenuation.minDistance).to.equal(0.5)140 expect(component1.resonance._attenuation.maxDistance).to.equal(100)141 expect(component1.resonance._attenuation._rolloff).to.equal('linear')142 expect(component1.resonance._directivity._alpha).to.equal(0.5)143 expect(component1.resonance._directivity._sharpness).to.equal(2)144 expect(component1.resonance._encoder._spreadIndex).to.equal(Math.min(359, Math.max(0, Math.round(20)))) // sourceWidth145 })146 test('visualization', () => {147 expect(srcEl1.getObject3D('audio-src').material.color.getHex()).to.equal(0xffffff)148 })149 })150 suite(`${cs} property updates`, () => {151 test('container position', () => {152 containerEl.setAttribute('position', '-10 -20 -30')153 document.querySelector('a-scene').object3D.updateMatrixWorld()154 // Audio source in world coordinates (changed).155 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: -6, y: -16, z: -26 }, { x: 0, y: 45, z: 0 })156 compareMatrixtoPosAndRot(srcEl2.object3D.matrixWorld, { x: -7, y: -17, z: -27 }, { x: 0, y: 0, z: 0 })157 // Resonance Source in world coordinates (changed).158 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: -6, y: -16, z: -26 }, { x: 0, y: 45, z: 0 })159 compareMatrixtoPosAndRot(component2.getMatrixWorld(), { x: -8, y: -18, z: -28 }, { x: 0, y: -90, z: 0 })160 // Resonance Source in room coordinates (unchanged).161 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 1, y: 1, z: 1 }, { x: 0, y: 45, z: 0 })162 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component2.resonance), { x: -1, y: -1, z: -1 }, { x: 0, y: -90, z: 0 })163 // Visualization in world coordinates (changed).164 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: -6, y: -16, z: -26 }, { x: 0, y: 45, z: 0 })165 compareMatrixtoPosAndRot(srcEl2.getObject3D('audio-src').matrixWorld, { x: -8, y: -18, z: -28 }, { x: 0, y: -90, z: 0 })166 })167 test('container rotation', () => {168 containerEl.setAttribute('rotation', '0 -180 0')169 document.querySelector('a-scene').object3D.updateMatrixWorld()170 // Audio source entity in world coordinates (changed).171 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: -5, y: 2, z: -7 }, { x: 0, y: -135, z: 0 })172 compareMatrixtoPosAndRot(srcEl2.object3D.matrixWorld, { x: -4, y: 1, z: -6 }, { x: 0, y: -180, z: 0 })173 // Resonance Source in world coordinates (changed).174 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: -5, y: 2, z: -7 }, { x: 0, y: -135, z: 0 })175 compareMatrixtoPosAndRot(component2.getMatrixWorld(), { x: -3, y: 0, z: -5 }, { x: 0, y: -270, z: 0 })176 // Resonance Source in room coordinates (unchanged).177 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 1, y: 1, z: 1 }, { x: 0, y: 45, z: 0 })178 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component2.resonance), { x: -1, y: -1, z: -1 }, { x: 0, y: -90, z: 0 })179 // Visualization in world coordinates (changed).180 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: -5, y: 2, z: -7 }, { x: 0, y: -135, z: 0 })181 compareMatrixtoPosAndRot(srcEl2.getObject3D('audio-src').matrixWorld, { x: -3, y: 0, z: -5 }, { x: 0, y: -270, z: 0 })182 })183 test('audio src position', () => {184 srcEl1.setAttribute(cs, 'position', '4 4 4')185 document.querySelector('a-scene').object3D.updateMatrixWorld()186 // Audio source entity in world coordinates (unchanged).187 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: 3, y: 2, z: 1 }, { x: 0, y: 45, z: 0 })188 // Resonance Source in world coordinates (changed).189 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: 6, y: 5, z: 4 }, { x: 0, y: 45, z: 0 })190 // Resonance Source in room coordinates (changed).191 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 4, y: 4, z: 4 }, { x: 0, y: 45, z: 0 })192 // Visualization in world coordinates (changed).193 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: 6, y: 5, z: 4 }, { x: 0, y: 45, z: 0 })194 })195 test('audio src rotation', () => {196 srcEl1.setAttribute(cs, 'rotation', '0 90 0')197 document.querySelector('a-scene').object3D.updateMatrixWorld()198 // Audio source entity in world coordinates (unchanged).199 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: 3, y: 2, z: 1 }, { x: 0, y: 45, z: 0 })200 // Resonance Source in world coordinates (changed).201 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: 3, y: 2, z: 1 }, { x: 0, y: 90, z: 0 })202 // Resonance Source in room coordinates (changed).203 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 1, y: 1, z: 1 }, { x: 0, y: 90, z: 0 })204 // Visualization in world coordinates (changed).205 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: 3, y: 2, z: 1 }, { x: 0, y: 90, z: 0 })206 })207 test('playback', () => {208 srcEl1.setAttribute(cs, { src: '', autoplay: false, loop: false })209 expect(srcEl1.getAttribute(cs).src).to.equal('')210 expect(srcEl1.getAttribute(cs).autoplay).to.equal(false)211 expect(srcEl1.getAttribute(cs).loop).to.equal(false)212 })213 test('acoustic parameters', () => {214 srcEl1.setAttribute(cs, {215 gain: 2.1,216 minDistance: 0.6,217 maxDistance: 99,218 rolloff: 'logarithmic',219 directivityPattern: '0.6 2.1',220 sourceWidth: 31221 })222 expect(component1.resonance.input.gain.value).to.be.closeTo(2.1, 0.01)223 expect(component1.resonance._attenuation.minDistance).to.equal(0.6)224 expect(component1.resonance._attenuation.maxDistance).to.equal(99)225 expect(component1.resonance._attenuation._rolloff).to.equal('logarithmic')226 expect(component1.resonance._directivity._alpha).to.equal(0.6)227 expect(component1.resonance._directivity._sharpness).to.equal(2.1)228 expect(component1.resonance._encoder._spreadIndex).to.equal(Math.min(359, Math.max(0, Math.round(31))))229 })230 })231 suite(`${cr} changes`, () => {232 test('position and orientation update', () => {233 roomEl.setAttribute('position', '-1 -2 2') // in world coordinates: -2 -4 -1234 roomEl.setAttribute('rotation', '0 -180 0')235 document.querySelector('a-scene').object3D.updateMatrixWorld()236 // Audio source in world coordinates (changed).237 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: -3, y: -3, z: -2 }, { x: 0, y: -135, z: 0 })238 compareMatrixtoPosAndRot(srcEl2.object3D.matrixWorld, { x: -2, y: -4, z: -1 }, { x: 0, y: -180, z: 0 })239 // Resonance Source in world coordinates (changed).240 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: -3, y: -3, z: -2 }, { x: 0, y: -135, z: 0 })241 compareMatrixtoPosAndRot(component2.getMatrixWorld(), { x: -1, y: -5, z: 0 }, { x: 0, y: 90, z: 0 })242 // Resonance Source in room coordinates (unchanged).243 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 1, y: 1, z: 1 }, { x: 0, y: 45, z: 0 })244 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component2.resonance), { x: -1, y: -1, z: -1 }, { x: 0, y: -90, z: 0 })245 })246 })247 suite(`${cs} changes`, () => {248 test('position and orientation update', () => {249 srcEl1.setAttribute('position', '2 2 2') // in world coordinates: 4 3 2250 srcEl1.setAttribute('rotation', '0 90 0')251 document.querySelector('a-scene').object3D.updateMatrixWorld()252 // Audio source in world coordinates (changed).253 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: 4, y: 3, z: 2 }, { x: 0, y: 90, z: 0 })254 // Resonance Source in world coordinates (changed).255 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: 4, y: 3, z: 2 }, { x: 0, y: 90, z: 0 })256 // Resonance Source in room coordinates (changed).257 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: 2, y: 2, z: 2 }, { x: 0, y: 90, z: 0 })258 // Visualization in world coordinates (changed).259 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: 4, y: 3, z: 2 }, { x: 0, y: 90, z: 0 })260 })261 })262 suite('audio source updating', () => {263 test('disconnect', () => {264 srcEl1.setAttribute(cs, 'src', null)265 expect(component1.connected).to.deep.equal({ element: false, stream: false })266 expect(component1.sound).to.equal(null)267 expect(srcEl1.getAttribute(cs).src).to.equal('')268 })269 test('connect resource', () => {270 srcEl1.setAttribute(cs, 'autoplay', false)271 srcEl1.setAttribute(cs, 'src', 'base/tests/assets/track.mp3')272 expect(component1.connected).to.deep.equal({ element: true, stream: false })273 expect(component1.sound).to.equal(component1.defaultAudioEl)274 expect(srcEl1.getAttribute(cs).src).to.equal(component1.defaultAudioEl)275 })276 test('connect stream (stub)', () => {277 /**278 * I have no reliable way to mock this yet. It works in Firefox, but in Chrome it doesn't:279 * its AudioNode.prototype.createMediaStreamSource() implementation doesn't accept a MediaStream280 * without an audio track, and I haven't found a way to mock that.281 * Also, Chrome doesn't fully support captureStream() yet.282 */283 /*284 const stream = new MediaStream()285 srcEl1.setAttribute(cs, 'src', stream)286 expect(component1.connected.element).to.equal(false)287 expect(component1.connected.stream).to.equal(true)288 expect(component1.sound).to.equal(stream)289 expect(srcEl1.getAttribute(cs).src).to.equal(stream)290 */291 })292 test('connect element', () => {293 srcEl1.setAttribute(cs, 'src', null)294 expect(component1.connected.element).to.equal(false)295 expect(component1.sound).to.equal(null)296 expect(srcEl1.getAttribute(cs).src).to.equal('')297 srcEl1.setAttribute(cs, 'src', asset)298 expect(component1.connected.element).to.equal(true)299 expect(component1.connected.stream).to.equal(false)300 expect(component1.sound).to.equal(asset)301 expect(srcEl1.getAttribute(cs).src).to.equal(asset)302 })303 test('connect element id', () => {304 srcEl1.setAttribute(cs, 'src', null)305 expect(component1.connected.element).to.equal(false)306 expect(component1.sound).to.equal(null)307 expect(srcEl1.getAttribute(cs).src).to.equal('')308 srcEl1.setAttribute(cs, 'src', '#track')309 expect(component1.connected.element).to.equal(true)310 expect(component1.connected.stream).to.equal(false)311 expect(component1.sound).to.equal(asset)312 expect(srcEl1.getAttribute(cs).src).to.equal(asset)313 })314 test('connect wrong src', () => {315 const fn1 = () => srcEl1.setAttribute(cs, 'src', '#unknown-identifier')316 const fn2 = () => srcEl1.setAttribute(cs, 'src', new HTMLElement())317 expect(fn1).to.throw(TypeError)318 expect(fn2).to.throw(TypeError)319 })320 })321 suite('addition and removal of source to room', () => {322 test('statically add src to room and exposeAPI', () => {323 expect(roomComponent.sources).to.be.an('array').that.includes(component2)324 expect(roomEl.sounds).to.be.an('array').that.includes(component1.sound)325 expect(roomEl.sounds).to.be.an('array').that.includes(component2.sound)326 expect(roomEl.audioSources).to.be.an('array').that.includes(component1)327 expect(roomEl.audioSources).to.be.an('array').that.includes(component2)328 })329 test('dynamically add src to room', done => {330 const srcEl3 = entityFactory({ [cs]: {} })331 srcEl3.addEventListener('componentinitialized', evt => {332 if (evt.detail.name !== cs) { return }333 expect(roomComponent.sources).to.be.an('array').that.includes(srcEl3.components[cs])334 expect(roomEl.sounds).to.be.an('array').that.includes(srcEl3.components[cs].sound)335 expect(roomEl.audioSources).to.be.an('array').that.includes(srcEl3.components[cs])336 done()337 })338 roomEl.appendChild(srcEl3)339 })340 test('remove src from room', done => {341 expect(roomComponent.sources).to.be.an('array').that.includes(component1)342 roomEl.addEventListener('child-detached', evt => {343 if (evt.detail.el !== srcEl1) { return }344 // room has no src anymore.345 expect(roomComponent.sources).to.be.an('array').that.does.not.include(component1)346 // src has no room anymore.347 expect(component1.room).to.equal(null)348 // src has no audio source anymore (because this is connected to the room's AudioContext).349 expect(component1.connected).to.deep.equal({ element: false, stream: false })350 done()351 })352 roomEl.removeChild(srcEl1)353 })354 test("src's audioroom-entered event", done => {355 const srcEl3 = entityFactory({ [cs]: {} })356 srcEl3.addEventListener('audioroom-entered', evt => {357 if (evt.detail.src === srcEl3 && evt.detail.room === roomEl) {358 done()359 }360 })361 roomEl.appendChild(srcEl3)362 })363 test("src's audioroom-left event", done => {364 srcEl1.addEventListener('audioroom-left', evt => {365 if (evt.detail.src === srcEl1 && evt.detail.room === roomEl) {366 done()367 }368 })369 roomEl.removeChild(srcEl1)370 })371 test(`remove component ${cr}`, done => {372 expect(roomEl.getObject3D('audio-room')).to.be.an.instanceOf(THREE.Object3D)373 expect(roomComponent.sources).to.be.an('array').that.includes(component1)374 roomEl.addEventListener('componentremoved', evt => {375 if (evt.detail.name !== cr) { return }376 expect(roomEl.getObject3D('audio-room')).to.equal(undefined)377 expect(roomComponent.sources).to.be.an('array').that.does.not.include(component1)378 expect(component1.room).to.equal(null)379 expect(component2.room).to.equal(null)380 done()381 })382 roomEl.removeAttribute(cr)383 })384 })385})386suite(`component ${cr} and ${cs} non-hierarchically attached`, () => {387 let roomEl1, roomEl2388 let srcEl0, srcEl1, srcEl2, srcEl3389 let component0, component1, component3, component2390 setup(done => {391 // ```html392 // <a-scene>393 // <a-entity position="-1 -1 -1"> <!-- containerEl -->394 // <a-entity resonance-audio-room id="roomEl1"> <!-- roomEl1 -->395 // <a-entity resonance-audio-src></a-entity> <!-- srcEl1 -->396 // <a-entity resonance-audio-src="room:#roomEl2;..."></a-entity> <!-- srcEl2 -->397 // <a-entity> <!-- childEl -->398 // <a-entity resonance-audio-src></a-entity> <!-- srcEl0 -->399 // </a-entity>400 // </a-entity>401 // </a-entity>402 // <a-entity resonance-audio-room id="roomEl2" position="3 3 3"></a-entity> <!-- roomEl2 -->403 // <a-entity404 // resonance-audio-src="audio-room:#roomEl1; position:2 2 2"></a-entity> <!-- srcEl3 -->405 // </a-scene>406 // ```407 // Expected:408 // roomEl1: srcEl1, srcEl3409 // roomEl2: srcEl2410 // no room: srcEl0411 putOnPage(412 sceneFactory([413 entityFactory(414 { position: '-1 -1 -1' },415 entityFactory({416 id: 'roomEl1',417 [cr]: {}418 }, [419 entityFactory({ id: 'srcEl1', [cs]: { visualize: true } }),420 entityFactory({ id: 'srcEl2', [cs]: { room: '#roomEl2', visualize: true } }),421 entityFactory({},422 entityFactory({ id: 'srcEl0', [cs]: {} })423 )424 ])425 ),426 entityFactory({427 id: 'roomEl2',428 position: '3 3 3',429 [cr]: {}430 }),431 entityFactory({432 id: 'srcEl3',433 [cs]: { room: '#roomEl1' },434 position: '2 2 2'435 })436 ])437 )438 roomEl1 = document.querySelector('#roomEl1')439 roomEl2 = document.querySelector('#roomEl2')440 srcEl1 = document.querySelectorAll(`[${cs}]`)[0]441 srcEl2 = document.querySelectorAll(`[${cs}]`)[1]442 srcEl0 = document.querySelectorAll(`[${cs}]`)[2]443 srcEl3 = document.querySelectorAll(`[${cs}]`)[3]444 component0 = srcEl0.components[cs]445 component1 = srcEl1.components[cs]446 component2 = srcEl2.components[cs]447 component3 = srcEl3.components[cs]448 srcEl3.addEventListener('audioroom-entered', () => {449 done()450 })451 })452 test('nonhierarchical attachment', () => {453 // src to room.454 expect(component2.room.el).to.equal(roomEl2)455 expect(component3.room.el).to.equal(roomEl1)456 // room to src.457 expect(roomEl2.components[cr].sources).to.be.an('array').and.to.include(component2)458 expect(roomEl1.components[cr].sources).to.be.an('array').and.to.include(component3)459 })460 test('nonhierarchical attachment prioritization', () => {461 // src to room.462 expect(component1.room.el).to.equal(roomEl1)463 expect(component2.room.el).to.not.equal(roomEl1)464 expect(component0.room).to.equal(null)465 // room to src.466 expect(roomEl1.components[cr].sources).to.be.an('array').and.to.include(component1)467 expect(roomEl1.components[cr].sources).to.be.an('array').and.to.not.include(component2)468 expect(roomEl1.components[cr].sources).to.be.an('array').and.to.not.include(component0)469 })470 test('position', () => {471 document.querySelector('a-scene').object3D.updateMatrixWorld()472 // Audio source entity in world coordinates.473 compareMatrixtoPosAndRot(srcEl2.object3D.matrixWorld, { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })474 // Resonance Source in world coordinates.475 compareMatrixtoPosAndRot(component2.getMatrixWorld(), { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })476 // Resonance Source in room coordinates.477 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component2.resonance), { x: -4, y: -4, z: -4 }, { x: 0, y: 0, z: 0 })478 // Visualization in world coordinates.479 compareMatrixtoPosAndRot(srcEl2.getObject3D('audio-src').matrixWorld, { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })480 })481 test('switch rooms', done => {482 srcEl1.addEventListener('audioroom-entered', evt => {483 document.querySelector('a-scene').object3D.updateMatrixWorld()484 expect(evt.detail.room).to.equal(roomEl2)485 expect(roomEl1.audioSources).to.be.an('array').that.does.not.include(component1)486 // Audio source entity in world coordinates (unchanged).487 compareMatrixtoPosAndRot(srcEl1.object3D.matrixWorld, { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })488 // Resonance Source in world coordinates (unchanged).489 compareMatrixtoPosAndRot(component1.getMatrixWorld(), { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })490 // Resonance Source in room coordinates (changed).491 compareMatrixtoPosAndRot(createMatrixFromResonanceSource(component1.resonance), { x: -4, y: -4, z: -4 }, { x: 0, y: 0, z: 0 })492 // Visualization in world coordinates (unchanged).493 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })494 done()495 })496 srcEl1.setAttribute(cs, 'room', document.querySelector('#roomEl2'))497 })498 test('leave room', done => {499 srcEl1.addEventListener('audioroom-left', evt => {500 expect(evt.detail.room).to.equal(roomEl1)501 expect(component1.room).to.equal(null)502 expect(component1.resonance).to.equal(null)503 expect(roomEl1.audioSources).to.be.an('array').that.does.not.include(component1)504 compareMatrixtoPosAndRot(srcEl1.getObject3D('audio-src').matrixWorld, { x: -1, y: -1, z: -1 }, { x: 0, y: 0, z: 0 })505 expect(srcEl1.getObject3D('audio-src').material.color.getHex()).to.equal(0xff0000)506 done()507 })508 srcEl1.setAttribute(cs, 'room', '#nonexistent-room')509 })510 teardown(() => {511 })512})513suite(`component ${crbb}`, () => {514 const [w, h, d] = [4.0400071144104, 2.970021963119507, 3.7050031423568726]515 let roomComponent516 let srcEl517 setup(done => {518 // ```html519 // <a-scene>520 // <a-entity521 // obj-model="522 // obj:url(base/tests/assets/room-model.obj);523 // mtl:url(base/tests/assets/room-materials.mtl)"524 // resonance-audio-room-bb="visualize:true"> <!-- roomEl -->525 // <a-entity resonance-audio-src></a-entity> <!-- el -->526 // </a-entity>527 // </a-scene>528 // ```529 putOnPage(530 sceneFactory([531 elementFactory('a-assets', {}),532 entityFactory({533 'obj-model': {534 obj: 'url(base/tests/assets/room-model.obj)',535 mtl: 'url(base/tests/assets/room-materials.mtl)'536 },537 [crbb]: { visualize: true }538 }, [539 entityFactory({ [cs]: {} })540 ])541 ])542 )543 document.querySelector(`[${crbb}]`).addEventListener('bounded-audioroom-loaded', evt => {544 roomComponent = evt.target.components[cr]545 srcEl = document.querySelector(`[${cs}]`)546 done()547 })548 })549 test('model loading, src entering the room, and bounded-audioroom-loaded event', () => {550 const delta = 0.000001551 expect(roomComponent.data.width).to.be.closeTo(w, delta, 'data.w delta')552 expect(roomComponent.data.height).to.be.closeTo(h, delta, 'data.h delta')553 expect(roomComponent.data.depth).to.be.closeTo(d, delta, 'data.d delta')554 expect(roomComponent.resonanceAudioScene._room.early._halfDimensions).to.deep.equal({ width: w / 2, height: h / 2, depth: d / 2 }, '_halfDimensions')555 const size = new THREE.Vector3()556 const o3d = roomComponent.el.getObject3D('audio-room')557 o3d.updateMatrixWorld()558 const box = new THREE.Box3().setFromObject(o3d)559 box.getSize(size)560 expect(size.x).to.be.closeTo(w, delta, 'size.w delta')561 expect(size.y).to.be.closeTo(h, delta, 'size.h delta')562 expect(size.z).to.be.closeTo(d, delta, 'size.d delta')563 expect(srcEl).to.not.equal(null)564 })565 teardown(() => {566 // This is to prevent the error "TypeError: this.el.getObject3D(...) is undefined" on this line:567 // https://github.com/aframevr/aframe/blob/master/src/components/geometry.js#L58568 roomComponent.el.removeAttribute('geometry')569 })...

Full Screen

Full Screen

test-amp-nested-menu.js

Source:test-amp-nested-menu.js Github

copy

Full Screen

1/**2 * Copyright 2019 The AMP HTML Authors. All Rights Reserved.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS-IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16import '../amp-nested-menu';17import * as fakeTimers from '@sinonjs/fake-timers';18import {Keys} from '#core/constants/key-codes';19import {htmlFor} from '#core/dom/static-template';20import {tryFocus} from '#core/dom';21const ANIMATION_TIMEOUT = 600;22describes.realWin(23 'amp-nested-menu component',24 {25 amp: {26 extensions: ['amp-nested-menu'],27 },28 },29 (env) => {30 let win, doc;31 let clock;32 beforeEach(() => {33 win = env.win;34 doc = win.document;35 clock = fakeTimers.withGlobal(win).install();36 });37 async function getNestedMenu(options) {38 options = options || {};39 const element = doc.createElement('amp-nested-menu');40 element.setAttribute('layout', 'fill');41 if (options.side) {42 element.setAttribute('side', options.side);43 }44 const ul = doc.createElement('ul');45 element.appendChild(ul);46 doc.body.appendChild(element);47 [1, 2, 3, 4].forEach((i) => {48 const item = htmlFor(doc)`49 <li>50 <button amp-nested-submenu-open></button>51 <div amp-nested-submenu>52 <button amp-nested-submenu-close></button>53 </div>54 </li>55 `;56 item57 .querySelector('[amp-nested-submenu]')58 .setAttribute('id', `submenu-${i}`);59 item60 .querySelector('[amp-nested-submenu-open]')61 .setAttribute('id', `open-${i}`);62 item63 .querySelector('[amp-nested-submenu-close]')64 .setAttribute('id', `close-${i}`);65 if (i == 3) {66 // nest submenu 3 inside submenu 167 const subUl = doc.createElement('ul');68 doc.getElementById('submenu-1').appendChild(subUl);69 subUl.appendChild(item);70 } else {71 ul.appendChild(item);72 }73 });74 await element.buildInternal();75 await element.layoutCallback();76 return element;77 }78 it('should set side attribute to right by default, but left for RTL', async () => {79 const menuEl1 = await getNestedMenu();80 expect(menuEl1.getAttribute('side')).to.equal('right');81 doc.documentElement.setAttribute('dir', 'rtl');82 const menuEl2 = await getNestedMenu();83 expect(menuEl2.getAttribute('side')).to.equal('left');84 });85 it('should open corresponding submenu when open element is clicked', async () => {86 const menuEl = await getNestedMenu();87 const openEl1 = doc.getElementById('open-1');88 const submenuEl1 = doc.getElementById('submenu-1');89 const openEl3 = doc.getElementById('open-3');90 const submenuEl3 = doc.getElementById('submenu-3');91 expect(menuEl.hasAttribute('child-open')).to.be.false;92 expect(submenuEl1.hasAttribute('open')).to.be.false;93 expect(openEl1.getAttribute('aria-expanded')).to.be.equal('false');94 const clickEvent = new Event('click', {bubbles: true});95 openEl1.dispatchEvent(clickEvent);96 clock.tick(ANIMATION_TIMEOUT);97 expect(menuEl.hasAttribute('child-open')).to.be.true;98 expect(submenuEl1.hasAttribute('open')).to.be.true;99 expect(submenuEl1.hasAttribute('child-open')).to.be.false;100 expect(submenuEl3.hasAttribute('open')).to.be.false;101 expect(openEl1.getAttribute('aria-expanded')).to.be.equal('true');102 expect(openEl3.getAttribute('aria-expanded')).to.be.equal('false');103 openEl3.dispatchEvent(clickEvent);104 clock.tick(ANIMATION_TIMEOUT);105 expect(openEl3.getAttribute('aria-expanded')).to.be.equal('true');106 expect(submenuEl1.hasAttribute('child-open')).to.be.true;107 expect(submenuEl3.hasAttribute('open')).to.be.true;108 });109 it('should close corresponding submenu when close element is clicked', async () => {110 const menuEl = await getNestedMenu();111 const impl = await menuEl.getImpl(false);112 const closeEl1 = doc.getElementById('close-1');113 const submenuEl1 = doc.getElementById('submenu-1');114 const closeEl3 = doc.getElementById('close-3');115 const submenuEl3 = doc.getElementById('submenu-3');116 const openEl3 = doc.getElementById('open-3');117 const openEl1 = doc.getElementById('open-1');118 impl.open_(submenuEl1);119 clock.tick(ANIMATION_TIMEOUT);120 impl.open_(submenuEl3);121 clock.tick(ANIMATION_TIMEOUT);122 expect(openEl1.getAttribute('aria-expanded')).to.be.equal('true');123 expect(openEl3.getAttribute('aria-expanded')).to.be.equal('true');124 expect(menuEl.hasAttribute('child-open')).to.be.true;125 expect(submenuEl1.hasAttribute('open')).to.be.true;126 const clickEvent = new Event('click', {bubbles: true});127 closeEl3.dispatchEvent(clickEvent);128 clock.tick(ANIMATION_TIMEOUT);129 expect(openEl3.getAttribute('aria-expanded')).to.be.equal('false');130 expect(submenuEl1.hasAttribute('child-open')).to.be.false;131 expect(submenuEl3.hasAttribute('open')).to.be.false;132 closeEl1.dispatchEvent(clickEvent);133 clock.tick(ANIMATION_TIMEOUT);134 expect(openEl1.getAttribute('aria-expanded')).to.be.equal('false');135 expect(menuEl.hasAttribute('child-open')).to.be.false;136 expect(submenuEl1.hasAttribute('open')).to.be.false;137 });138 it('should return to root menu on reset', async () => {139 const menuEl = await getNestedMenu();140 const impl = await menuEl.getImpl(false);141 const submenuEl1 = doc.getElementById('submenu-1');142 const submenuEl3 = doc.getElementById('submenu-3');143 impl.open_(submenuEl1);144 impl.open_(submenuEl3);145 expect(menuEl.hasAttribute('child-open')).to.be.true;146 expect(submenuEl1.hasAttribute('child-open')).to.be.true;147 expect(submenuEl1.hasAttribute('open')).to.be.true;148 expect(submenuEl3.hasAttribute('open')).to.be.true;149 impl.reset();150 expect(menuEl.hasAttribute('child-open')).to.be.false;151 expect(submenuEl1.hasAttribute('child-open')).to.be.false;152 expect(submenuEl1.hasAttribute('open')).to.be.false;153 expect(submenuEl3.hasAttribute('open')).to.be.false;154 });155 it('should return to parent menu when left arrow key is pressed and side=right', async () => {156 const menuEl = await getNestedMenu({'side': 'right'});157 const impl = await menuEl.getImpl(false);158 const submenuEl = doc.getElementById('submenu-1');159 impl.open_(submenuEl);160 expect(menuEl.hasAttribute('child-open')).to.be.true;161 expect(submenuEl.hasAttribute('open')).to.be.true;162 const keyEvent = new KeyboardEvent('keydown', {key: Keys.LEFT_ARROW});163 menuEl.dispatchEvent(keyEvent);164 expect(menuEl.hasAttribute('child-open')).to.be.false;165 expect(submenuEl.hasAttribute('open')).to.be.false;166 });167 it('should return to parent menu when right arrow key is pressed and side=left', async () => {168 const menuEl = await getNestedMenu({'side': 'left'});169 const impl = await menuEl.getImpl(false);170 const submenuEl = doc.getElementById('submenu-1');171 impl.open_(submenuEl);172 expect(menuEl.hasAttribute('child-open')).to.be.true;173 expect(submenuEl.hasAttribute('open')).to.be.true;174 const keyEvent = new KeyboardEvent('keydown', {key: Keys.RIGHT_ARROW});175 menuEl.dispatchEvent(keyEvent);176 expect(menuEl.hasAttribute('child-open')).to.be.false;177 expect(submenuEl.hasAttribute('open')).to.be.false;178 });179 it('should open submenu when right arrow key is pressed, side=right and open button has focus', async () => {180 const menuEl = await getNestedMenu({'side': 'right'});181 const openEl = doc.getElementById('open-1');182 const submenuEl = doc.getElementById('submenu-1');183 expect(menuEl.hasAttribute('child-open')).to.be.false;184 expect(submenuEl.hasAttribute('open')).to.be.false;185 tryFocus(openEl);186 expect(doc.activeElement).to.equal(openEl);187 const keyEvent = new KeyboardEvent('keydown', {188 key: Keys.RIGHT_ARROW,189 bubbles: true,190 });191 openEl.dispatchEvent(keyEvent);192 expect(menuEl.hasAttribute('child-open')).to.be.true;193 expect(submenuEl.hasAttribute('open')).to.be.true;194 });195 it('should open submenu when left arrow key is pressed, side=left and open button has focus', async () => {196 const menuEl = await getNestedMenu({'side': 'left'});197 const openEl = doc.getElementById('open-1');198 const submenuEl = doc.getElementById('submenu-1');199 expect(menuEl.hasAttribute('child-open')).to.be.false;200 expect(submenuEl.hasAttribute('open')).to.be.false;201 tryFocus(openEl);202 expect(doc.activeElement).to.equal(openEl);203 const keyEvent = new KeyboardEvent('keydown', {204 key: Keys.LEFT_ARROW,205 bubbles: true,206 });207 openEl.dispatchEvent(keyEvent);208 expect(menuEl.hasAttribute('child-open')).to.be.true;209 expect(submenuEl.hasAttribute('open')).to.be.true;210 });211 it('should shift focus between list items when up/down arrow key is pressed', async () => {212 await getNestedMenu();213 const openEl1 = doc.getElementById('open-1');214 const openEl2 = doc.getElementById('open-2');215 tryFocus(openEl1);216 expect(doc.activeElement).to.equal(openEl1);217 const downKeyEvent = new KeyboardEvent('keydown', {218 key: Keys.DOWN_ARROW,219 bubbles: true,220 });221 openEl1.dispatchEvent(downKeyEvent);222 expect(doc.activeElement).to.equal(openEl2);223 const upKeyEvent = new KeyboardEvent('keydown', {224 key: Keys.UP_ARROW,225 bubbles: true,226 });227 openEl2.dispatchEvent(upKeyEvent);228 expect(doc.activeElement).to.equal(openEl1);229 });230 it('should focus on first/last items when home/end key is pressed', async () => {231 await getNestedMenu();232 const openEl1 = doc.getElementById('open-1');233 const openEl4 = doc.getElementById('open-4');234 tryFocus(openEl1);235 expect(doc.activeElement).to.equal(openEl1);236 const endKeyEvent = new KeyboardEvent('keydown', {237 key: Keys.END,238 bubbles: true,239 });240 openEl1.dispatchEvent(endKeyEvent);241 expect(doc.activeElement).to.equal(openEl4);242 const homeKeyEvent = new KeyboardEvent('keydown', {243 key: Keys.HOME,244 bubbles: true,245 });246 openEl4.dispatchEvent(homeKeyEvent);247 expect(doc.activeElement).to.equal(openEl1);248 });249 it('should shift focus to close/open button when submenu is opened/closed, respectively', async () => {250 const menuEl = await getNestedMenu();251 const impl = await menuEl.getImpl(false);252 const openEl = doc.getElementById('open-1');253 const closeEl = doc.getElementById('close-1');254 const submenuEl = doc.getElementById('submenu-1');255 impl.open_(submenuEl);256 clock.tick(ANIMATION_TIMEOUT);257 expect(doc.activeElement).to.equal(closeEl);258 impl.close_(submenuEl);259 clock.tick(ANIMATION_TIMEOUT);260 expect(doc.activeElement).to.equal(openEl);261 });262 }...

Full Screen

Full Screen

background.js

Source:background.js Github

copy

Full Screen

1// console.log('hello');2function Acl_show_Image() {3 var img_src= document.getElementById("top_image").value;4 jQuery("#top_img_prev").attr('src',img_src);5}6function Acl_top_img_clear() {7 document.getElementById("top_image").value ="";8}9//Set Value of Drop Down10jQuery(document).ready(function(){11 //Top Background Select12 // var top_bg_type = frontend_ajax_object.top_bg_type;13 if ( frontend_ajax_object.top_bg_type.length != 0 && frontend_ajax_object.top_bg_type != undefined ) {14 var top_bg_type = frontend_ajax_object.top_bg_type;15 } else {16 var top_bg_type = '' ;17 }18 jQuery("#select-background").val();19 getComboid();20 21 //Top Background strech22 var top_cover = frontend_ajax_object.top_cover;23 if( top_cover == "yes"){24 jQuery("#div-on-strech").hide();25 } else {26 jQuery("#div-on-strech").show();27 } 28 29 //Top Background Repeat 30 var top_repeat = frontend_ajax_object.top_repeat;31 if (top_repeat != ""){32 jQuery("#top_bg_repeat").val();33 }34 //Top Background Position 35 var top_position = frontend_ajax_object.top_position;36 if(top_position != ""){ 37 jQuery("#top_bg_position").val();38 }39 //Top Background Attachment 40 var top_attachment = frontend_ajax_object.top_attachment;41 if(top_attachment != ""){42 jQuery("#top_bg_attachment").val();43 };44 //Top SlideShow No 45 var top_attachment = frontend_ajax_object.top_slideshow_no;46 if(top_attachment != ""){47 jQuery("#top_slideshow_no").val();48 };49 //Top Slide Animation 50 var top_attachment = frontend_ajax_object.top_bg_slider_animation;51 if(top_attachment != ""){52 jQuery("#top_bg_slider_animation").val();53 };54});55function OnChangeCheckbox (checkbox) {56 if (checkbox.checked) { 57 jQuery("#div-on-strech").hide();58 }59 else { 60 jQuery("#div-on-strech").show();61 }62}63function getComboid() {64 var optionvalue = jQuery( "#select-background option:selected" ).val();65 jQuery(".no-background").hide();66 67 if(optionvalue== "static-background-color")68 {69 jQuery( "#div-bakground-color" ).show();70 }71 if(optionvalue== "static-background-image")72 {73 jQuery( "#div-bakground-image" ).show();74 }75 if(optionvalue== "slider-background")76 {77 jQuery( "#div-bakground-Slideshow" ).show();78 }79}80function set_slideshow(){81 number = jQuery("#top_slideshow_no").val(); 82 for(i=1;i<=6;i++){83 if(i<=number){84 jQuery("#slideshow_settings_"+i).show(500);85 }86 else{87 jQuery("#slideshow_settings_"+i).hide(500);88 }89 }90}91function Custom_login_top(Action, id){ 92 if(Action == "topbgSave") {93 (function() {94 var dlgtrigger1 = document.querySelector( '[data-dialog1]' ),95 somedialog1 = document.getElementById( dlgtrigger1.getAttribute( 'data-dialog1' ) ),96 // svg..97 morphEl1 = somedialog1.querySelector( '#morph-shape1' ),98 s1 = Snap( morphEl1.querySelector( 'svg' ) ),99 path = s1.select( 'path' ),100 steps = { 101 open : morphEl1.getAttribute( 'data-morph-open1' ),102 close : morphEl1.getAttribute( 'data-morph-close1' )103 },104 dlg = new DialogFx( somedialog1, {105 onOpenDialog : function( instance ) {106 // animate path107 setTimeout(function() {108 path.stop().animate( { 'path' : steps.open }, 1500, mina.elastic );109 }, 250 );110 },111 onCloseDialog : function( instance ) {112 // animate path113 path.stop().animate( { 'path' : steps.close }, 250, mina.easeout );114 }115 } );116 dlgtrigger1.addEventListener( 'click', dlg.toggle.bind(dlg) );117 })();118 // Top Background Type Option119 var select_bg_value = jQuery( "#select-background option:selected" ).val();120 121 //Top Background Color122 var top_background_color = jQuery("#top-background-color").val();123 124 //Top background Image URL125 var top_bg_image = jQuery("#top_image").val();126 127 //Top background Strech128 if (jQuery('#bg-strech').is(":checked")) {129 var top_cover = "yes";130 } else {131 var top_cover = "no";132 }133 var top_bg_repeat = jQuery( "#top_bg_repeat option:selected" ).val();134 var top_bg_position = jQuery( "#top_bg_position option:selected" ).val();135 var top_bg_attachment = jQuery( "#top_bg_attachment option:selected" ).val();136 var top_slideshow_no = jQuery( "#top_slideshow_no option:selected" ).val();137 var top_bg_slider_animation = jQuery( "#top_bg_slider_animation option:selected" ).val(); 138 139 // Slider image URL and Label Save140 number = jQuery("#top_slideshow_no").val();141 var a =[];142 var b =[];143 for(i=1;i<=6;i++){144 if(i<=number){ 145 a[i] =document.getElementById("simages-"+i).src;146 b[i] =jQuery("#image_label-"+i).val(); 147 } else {148 a[i]= '';149 b[i] = "";150 }151 }152 var PostData = "Action=" + Action + "&select_bg_value=" + select_bg_value + "&top_background_color=" + top_background_color + "&top_bg_image=" + top_bg_image + "&top_cover=" + top_cover + "&top_bg_repeat=" + top_bg_repeat + "&top_bg_position=" + top_bg_position + "&top_bg_attachment=" + top_bg_attachment + "&top_slideshow_no=" + top_slideshow_no + "&top_bg_slider_animation=" + top_bg_slider_animation + "&Slidshow_image_1=" + a[1] + "&Slidshow_image_2=" + a[2] + "&Slidshow_image_3=" + a[3] + "&Slidshow_image_4=" + a[4] + "&Slidshow_image_5=" + a[5] + "&Slidshow_image_6=" + a[6] + "&image_label_1=" + b[1] + "&image_label_2=" + b[2] + "&image_label_3=" + b[3] + "&image_label_4=" + b[4] + "&image_label_5=" + b[5] + "&image_label_6=" + b[6];153 jQuery.ajax({154 dataType : 'html',155 type: 'POST',156 url : location.href,157 cache: false,158 data : PostData,159 complete : function() { },160 success: function(data) { 161 // message box open162 jQuery(".dialog-button1").click(); 163 // Function to close message box164 setTimeout(function(){165 jQuery("#dialog-close-button1").click();166 }, 1000); 167 }168 });169 }170 171 // Save Message box Close On Mouse Hover172 document.getElementById('dialog-close-button1').disabled = false;173 jQuery('#dialog-close-button1').hover(function () {174 jQuery("#dialog-close-button1").click();175 document.getElementById('dialog-close-button1').disabled = true; 176 });177 178 // Reset Message box Close On Mouse Hover179 document.getElementById('dialog-close-button11').disabled = false;180 jQuery('#dialog-close-button11').hover(function () {181 jQuery("#dialog-close-button11").click();182 document.getElementById('dialog-close-button11').disabled = true; 183 });184 185 if(Action == "topbgReset") {186 (function() {187 var dlgtrigger1 = document.querySelector( '[data-dialog11]' ),188 somedialog1 = document.getElementById( dlgtrigger1.getAttribute( 'data-dialog11' ) ),189 // svg..190 morphEl1 = somedialog1.querySelector( '#morph-shape1' ),191 s1 = Snap( morphEl1.querySelector( 'svg' ) ),192 path = s1.select( 'path' ),193 steps = { 194 open : morphEl1.getAttribute( 'data-morph-open1' ),195 close : morphEl1.getAttribute( 'data-morph-close1' )196 },197 dlg = new DialogFx( somedialog1, {198 onOpenDialog : function( instance ) {199 // animate path200 setTimeout(function() {201 path.stop().animate( { 'path' : steps.open }, 1500, mina.elastic );202 }, 250 );203 },204 onCloseDialog : function( instance ) {205 // animate path206 path.stop().animate( { 'path' : steps.close }, 250, mina.easeout );207 }208 } );209 dlgtrigger1.addEventListener( 'click', dlg.toggle.bind(dlg) );210 })();211 212 var PostData = "Action=" + Action ;213 jQuery.ajax({214 dataType : 'html',215 type: 'POST',216 url : location.href,217 cache: false,218 data : PostData,219 complete : function() { },220 success: function(data) {221 // Show Background Image Option222 jQuery(".no-background").hide();223 jQuery( "#div-bakground-image" ).show();224 //Top Background Select225 jQuery("#select-background").val('static-background-image');226 //Top Background Repeat 227 jQuery("#top_bg_repeat").val('repeat');228 //Top Background Position 229 jQuery("#top_bg_position").val('left top');230 //Top Background Attachment 231 jQuery("#top_bg_attachment").val('fixed');232 //Top SlideShow No 233 jQuery("#top_slideshow_no").val('6');234 //Top Slider Animation 235 jQuery("#top_bg_slider_animation").val('slider-style1');236 // Top Background Image237 document.getElementById("top_image").value = "/images/3d-background.jpg";238 // Top Background Color239 jQuery("#td-top-background-color a.wp-color-result").closest("a").css({"background-color": "#f9fad2"});240 //hide Image slider241 number = jQuery("#top_slideshow_no").val();242 for(i=1;i<=6;i++){243 if(i<=number){244 jQuery("#slideshow_settings_"+i).show();245 } else {246 jQuery("#slideshow_settings_"+i).hide();247 }248 }249 //set default value to Image slider250 for(i=1;i<=6;i++){251 jQuery("#simages-"+i).attr('src','/images/rpg-default.jpg' );252 }253 jQuery(".dialog-button11").click();254 // Function to close message box255 setTimeout(function(){256 jQuery("#dialog-close-button11").click();257 }, 1000);258 }259 });260 }...

Full Screen

Full Screen

Tabs.test.js

Source:Tabs.test.js Github

copy

Full Screen

1/* eslint-env mocha */2/* global proclaim sinon */3import fixtures from './helpers/fixtures.js';4sinon.assert.expose(proclaim, {5 includeFail: false,6 prefix: ''7});8import Tabs from '../main.js';9let testTabs;10let tabsEl;11let tabContentEl1;12let tabContentEl2;13let tabContentEl3;14describe('tabs', () => {15 beforeEach(() => {16 fixtures.insertSimple();17 tabsEl = document.querySelector('[data-o-component=o-tabs]');18 tabContentEl1 = document.getElementById('tabContent1');19 tabContentEl2 = document.getElementById('tabContent2');20 tabContentEl3 = document.getElementById('tabContent3');21 testTabs = new Tabs(tabsEl);22 });23 afterEach(() => {24 testTabs = null;25 tabsEl = null;26 tabContentEl1 = null;27 tabContentEl2 = null;28 tabContentEl3 = null;29 fixtures.reset();30 });31 it('destroy()', () => {32 testTabs.destroy();33 proclaim.isFalse(tabsEl.classList.contains('o-tabs--js'));34 sinon.spy(testTabs, 'selectTab');35 const clickEvent = document.createEvent('Event');36 clickEvent.initEvent('click', true, true);37 tabsEl.querySelectorAll('li a')[2].dispatchEvent(clickEvent);38 proclaim.notCalled(testTabs.selectTab);39 proclaim.equal(tabContentEl1.getAttribute('aria-expanded'), 'true');40 proclaim.equal(tabContentEl1.getAttribute('aria-hidden'), 'false');41 proclaim.equal(tabContentEl2.getAttribute('aria-expanded'), 'true');42 proclaim.equal(tabContentEl2.getAttribute('aria-hidden'), 'false');43 proclaim.equal(tabContentEl3.getAttribute('aria-expanded'), 'true');44 proclaim.equal(tabContentEl3.getAttribute('aria-hidden'), 'false');45 });46 describe('tabs behaviour', () => {47 afterEach(() => {48 testTabs.destroy();49 });50 it('is defined', () => {51 proclaim.isDefined(Tabs);52 proclaim.isDefined(Tabs.init);53 });54 it('is has correct initial dom changes', () => {55 proclaim.isTrue(tabsEl.hasAttribute('data-o-tabs--js'));56 proclaim.strictEqual(tabsEl.querySelectorAll('li')[0].getAttribute('aria-controls'), 'tabContent1');57 proclaim.strictEqual(tabsEl.querySelectorAll('li')[1].getAttribute('aria-controls'), 'tabContent2');58 proclaim.strictEqual(tabsEl.querySelectorAll('li')[2].getAttribute('aria-controls'), 'tabContent3');59 // Aria labelledby is set correctly:60 proclaim.strictEqual(tabsEl.querySelectorAll('li')[2].querySelector('a').id, 'tabContent3-label');61 proclaim.strictEqual(tabContentEl3.getAttribute('aria-labelledby'), 'tabContent3-label');62 // Focusable elements63 [].forEach.call(document.querySelectorAll('.should-be-focusable'), function (element) {64 proclaim.equal(element.getAttribute('tabindex'), '0');65 });66 [].forEach.call(document.querySelectorAll('.should-not-be-focusable'), function (element) {67 proclaim.equal(element.getAttribute('tabindex'), '-1');68 });69 });70 it('has correct initial state', () => {71 proclaim.equal(tabsEl.querySelectorAll('li')[0].getAttribute('aria-selected'), 'true');72 proclaim.equal(tabsEl.querySelectorAll('li')[1].getAttribute('aria-selected'), 'false');73 proclaim.equal(tabsEl.querySelectorAll('li')[2].getAttribute('aria-selected'), 'false');74 proclaim.equal(tabContentEl1.getAttribute('aria-expanded'), 'true');75 proclaim.equal(tabContentEl1.getAttribute('aria-hidden'), 'false');76 proclaim.equal(tabContentEl2.getAttribute('aria-expanded'), 'false');77 proclaim.equal(tabContentEl2.getAttribute('aria-hidden'), 'true');78 proclaim.equal(tabContentEl3.getAttribute('aria-expanded'), 'false');79 proclaim.equal(tabContentEl3.getAttribute('aria-hidden'), 'true');80 });81 it('can set the config declaratively', () => {82 proclaim.isTrue(testTabs.config.disablefocus);83 });84 it('selectTab(1)', () => {85 testTabs.selectTab(1);86 proclaim.equal(tabsEl.querySelectorAll('li')[0].getAttribute('aria-selected'), 'false');87 proclaim.equal(tabsEl.querySelectorAll('li')[1].getAttribute('aria-selected'), 'true');88 proclaim.equal(tabsEl.querySelectorAll('li')[2].getAttribute('aria-selected'), 'false');89 proclaim.equal(tabContentEl1.getAttribute('aria-expanded'), 'false');90 proclaim.equal(tabContentEl1.getAttribute('aria-hidden'), 'true');91 proclaim.equal(tabContentEl2.getAttribute('aria-expanded'), 'true');92 proclaim.equal(tabContentEl2.getAttribute('aria-hidden'), 'false');93 proclaim.equal(tabContentEl3.getAttribute('aria-expanded'), 'false');94 proclaim.equal(tabContentEl3.getAttribute('aria-hidden'), 'true');95 });96 it('click tab', () => {97 sinon.spy(testTabs, 'selectTab');98 const clickEvent = document.createEvent('Event');99 clickEvent.initEvent('click', true, true);100 tabsEl.querySelectorAll('li a')[2].dispatchEvent(clickEvent);101 proclaim.calledWith(testTabs.selectTab, 2);102 tabsEl.querySelectorAll('li a')[1].dispatchEvent(clickEvent);103 proclaim.calledWith(testTabs.selectTab, 1);104 tabsEl.querySelectorAll('li a')[0].dispatchEvent(clickEvent);105 proclaim.calledWith(testTabs.selectTab, 0);106 });107 it('enter key press tab', () => {108 sinon.spy(testTabs, 'selectTab');109 const keyPressEvent = document.createEvent('Event');110 keyPressEvent.keyCode = 13;111 keyPressEvent.initEvent('keypress', true, true);112 tabsEl.querySelectorAll('li a')[2].dispatchEvent(keyPressEvent);113 proclaim.calledWith(testTabs.selectTab, 2);114 tabsEl.querySelectorAll('li a')[1].dispatchEvent(keyPressEvent);115 proclaim.calledWith(testTabs.selectTab, 1);116 tabsEl.querySelectorAll('li a')[0].dispatchEvent(keyPressEvent);117 proclaim.calledWith(testTabs.selectTab, 0);118 });119 it('does not auto initialise when "data-o-tabs-autoconstruct=false" is set', () => {120 fixtures.reset();121 fixtures.insertSimple();122 tabsEl = document.querySelector('[data-o-component=o-tabs]');123 tabsEl.setAttribute('data-o-tabs-autoconstruct', 'false');124 Tabs.init();125 proclaim.isFalse(tabsEl.hasAttribute('data-o-tabs--js'));126 });127 describe('hash updating', () => {128 const rebuildTabs = (withUpdateUrl = true) => {129 fixtures.reset();130 fixtures.insertSimple();131 if (withUpdateUrl) {132 tabsEl.setAttribute('data-o-tabs-update-url', '');133 }134 tabsEl.setAttribute('data-o-tabs-disablefocus', 'false');135 testTabs.destroy();136 testTabs = new Tabs(tabsEl);137 };138 beforeEach(() => {139 location.hash = '';140 });141 afterEach(() => {142 tabsEl.removeAttribute('data-o-tabs-update-url');143 });144 it('Should update the hash part of the url to the id of the active tab', () => {145 rebuildTabs();146 testTabs.selectTab(0);147 const expectedHash = document.querySelector('.o-tabs li:first-child a').hash;148 proclaim.strictEqual(location.hash, expectedHash);149 });150 it('Should not update the hash part of the url on tab initialisation', () => {151 rebuildTabs();152 proclaim.strictEqual(location.hash, '');153 });154 it('Should not update the url if the data attribute is not present', () => {155 rebuildTabs(false);156 testTabs.selectTab(0);157 proclaim.strictEqual(location.hash, '');158 });159 it('Should open the correct tab onload if the hash is present', (done) => {160 location.hash = '#tabContent3';161 tabsEl.addEventListener('oTabs.tabSelect', (ev) => {162 proclaim.strictEqual(ev.detail.selected, 2);163 done();164 });165 rebuildTabs();166 });167 it('Should respond to the hashchange event', (done) => {168 rebuildTabs();169 testTabs.selectTab(0);170 location.hash = '#tabContent3';171 tabsEl.addEventListener('oTabs.tabSelect', (ev) => {172 proclaim.strictEqual(ev.detail.selected, 2);173 done();174 });175 });176 });177 });...

Full Screen

Full Screen

dom.test.js

Source:dom.test.js Github

copy

Full Screen

...23 className,24 title,25 customAttr26 }));27 expect(el1.getAttribute('class')).toBe(className);28 // className 属性应当特殊处理29 expect(el1.hasAttribute('classname')).toBe(false);30 expect(el1.getAttribute('title')).toBe(title);31 expect(el1.getAttribute('customAttr')).toBe(customAttr);32 const el2 = DOM.createElement('div', null, el1);33 expect(el2.hasChildNodes(el1)).toBe(true);34 const el3 = DOM.createElement('div', null, el1, el2);35 expect(el3.hasChildNodes(el1)).toBe(true);36 expect(el3.hasChildNodes(el2)).toBe(true);37 });38 it('prependTo()', function () {39 const parentEl = document.createElement('div');40 const childEl1 = document.createElement('span');41 const childEl2 = document.createElement('div');42 parentEl.appendChild(childEl1);43 DOM.prependTo(childEl2, parentEl);44 expect(parentEl.firstChild).toBe(childEl2);45 });...

Full Screen

Full Screen

paging.js

Source:paging.js Github

copy

Full Screen

...141 slideElements: [el1, el2, el3]142 });143 paging.nextBus.plug(control.key(39));144 paging.prevBus.plug(control.key(37));145 assert(el1.getAttribute('visible') === '1');146 assert(el2.getAttribute('visible') === null);147 assert(el3.getAttribute('visible') === null);148 rightKey(); // 1 > 2149 assert(el1.getAttribute('visible') === null);150 assert(el2.getAttribute('visible') === '1');151 assert(el3.getAttribute('visible') === null);152 rightKey(); // 2 > 3153 assert(el1.getAttribute('visible') === null);154 assert(el2.getAttribute('visible') === null);155 assert(el3.getAttribute('visible') === '1');156 leftKey(); // 2 > 1157 assert(el1.getAttribute('visible') === null);158 assert(el2.getAttribute('visible') === '1');159 assert(el3.getAttribute('visible') === null);160 });...

Full Screen

Full Screen

done-sort.js

Source:done-sort.js Github

copy

Full Screen

...11 12 }13 tasksElements.sort((el1, el2) =>{14 return isAsc 15 ? dates[el2.getAttribute('data-id')] - dates[el1.getAttribute('data-id')]16 : dates[el1.getAttribute('data-id')] - dates[el2.getAttribute('data-id')]17 })18 19 }20 21 function sortTaskBytext(tasksElements) {22 let isAsc = openSelect.value == 'asc-text'23 tasksElements.sort((el1, el2) =>{24 let isMore = el2.querySelector('.text-to').textContent.toLowerCase() > el1.querySelector('.text-to').textContent.toLowerCase()25 if (isAsc){26 return isMore27 ? 128 : -129 } else {30 return isMore31 ? -132 : 133 }34 })35 }36 37 let openSelect = document.querySelector('.option-open')38 openSelect.addEventListener('change', function(){39 let tasksElements = document.querySelectorAll('.task-open .task-o')40 let tasksElementsArray = Array.from(tasksElements)41 let isTextSorting = ['asc-text', 'desc-text'].includes(openSelect.value)42 if (isTextSorting){43 sortTaskBytext(tasksElementsArray)44 } else {45 sortTaskBydate(tasksElementsArray)46 }47 48 49 openTaskopenSelection.innerHTML =""50 tasksElementsArray.forEach((el) =>{51 openTaskopenSelection.appendChild(el)52 })53 54 })55 56 let doneSelect = document.querySelector('.option-done')57 doneSelect.addEventListener('change', function(){58 let isAsc = doneSelect.value == 'asc'59 let tasksElements = document.querySelectorAll('.task-done .task-o')60 let tasksElementsArray = Array.from(tasksElements)61 let dates = {}62 for (let i = 0; i<tasksElements.length; i++){63 let dateElement = tasksElements[i].querySelector('.time-done')64 let date = Date.parse(dateElement.getAttribute('data-value'))65 let id = tasksElements[i].getAttribute('data-id')66 dates[id] = date67 } console.log(dates)68 tasksElementsArray.sort((el1, el2) =>{69 return isAsc 70 ? dates[el2.getAttribute('data-id')] - dates[el1.getAttribute('data-id')]71 : dates[el1.getAttribute('data-id')] - dates[el2.getAttribute('data-id')]72 })73 openTaskdoneSelection.innerHTML =""74 tasksElementsArray.forEach((el) =>{75 openTaskdoneSelection.appendChild(el)76 })77 78 })...

Full Screen

Full Screen

15.js

Source:15.js Github

copy

Full Screen

...45function changePosition(el1, el2){46 let temp = el1.classList.value;47 el1.classList.value = el2.classList.value;48 el2.classList.value = temp;49 temp = el1.getAttribute("x");50 el1.setAttribute("x", el2.getAttribute("x"));51 el2.setAttribute("x",temp);52 temp = el1.getAttribute("y");53 el1.setAttribute("y", el2.getAttribute("y"));54 el2.setAttribute("y",temp);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const attribute = await el1.getAttribute("name");2const attribute = await el1.getAttribute("text");3const attribute = await el1.getAttribute("text");4const attribute = await el1.getAttribute("text");5const attribute = await el1.getAttribute("Name");6const attribute = await el1.getAttribute("text");7const attribute = await el1.getAttribute("Name");8const attribute = await el1.getAttribute("name");9const attribute = await el1.getAttribute("text");

Full Screen

Using AI Code Generation

copy

Full Screen

1var attr = el1.getAttribute("name");2System.out.println("Attribute value: " + attr);3var attr = el1.getAttribute("name");4System.out.println("Attribute value: " + attr);5var attr = el1.getAttribute("name");6System.out.println("Attribute value: " + attr);7var attr = el1.getAttribute("name");8System.out.println("Attribute value: " + attr);9var attr = el1.getAttribute("name");10System.out.println("Attribute value: " + attr);11var attr = el1.getAttribute("name");12System.out.println("Attribute value: " + attr);13var attr = el1.getAttribute("name");14System.out.println("Attribute value: " + attr);15var attr = el1.getAttribute("name");16System.out.println("Attribute value: " + attr);17var attr = el1.getAttribute("name");18System.out.println("Attribute value: " + attr);

Full Screen

Using AI Code Generation

copy

Full Screen

1const attribute = await el1.getAttribute('name');2console.log(attribute);3const attribute = await el1.getAttribute('name');4console.log(attribute);5const attribute = await el1.getAttribute('name');6console.log(attribute);7const attribute = await el1.getAttribute('name');8console.log(attribute);9const attribute = await el1.getAttribute('name');10console.log(attribute);11const attribute = await el1.getAttribute('name');12console.log(attribute);13const attribute = await el1.getAttribute('name');14console.log(attribute);15const attribute = await el1.getAttribute('name');16console.log(attribute);17const attribute = await el1.getAttribute('name

Full Screen

Using AI Code Generation

copy

Full Screen

1var el1 = driver.findElement(By.id("someId"));2var value = el1.getAttribute('value');3console.log("Value of attribute is: " + value);4var el2 = driver.findElement(By.id("someId"));5var value = el2.getAttribute('value');6console.log("Value of attribute is: " + value);7var el1 = driver.findElement(By.id("someId"));8var value = el1.getAttribute('value');9console.log("Value of attribute is: " + value);10var el2 = driver.findElement(By.id("someId"));11var value = el2.getAttribute('value');12console.log("Value of attribute is: " + value);13var el1 = driver.findElement(By.id("someId"));14var value = el1.getAttribute('value');15console.log("Value of attribute is: " + value);16var el2 = driver.findElement(By.id("someId"));17var value = el2.getAttribute('value');18console.log("Value of attribute is: " + value);19var el1 = driver.findElement(By.id("someId"));20var value = el1.getAttribute('value');21console.log("Value of attribute is: " + value);22var el2 = driver.findElement(By.id("someId"));23var value = el2.getAttribute('value');24console.log("Value of attribute is: " + value);25var el1 = driver.findElement(By.id("someId"));26var value = el1.getAttribute('value');27console.log("Value of attribute is: " + value);28var el2 = driver.findElement(By.id("someId"));29var value = el2.getAttribute('value');30console.log("Value of attribute is: " + value);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful