mirror of
https://github.com/CoderSherlock/CoderSherlock.github.io.git
synced 2026-06-13 08:08:10 -07:00
I_changed_another_theme
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>active-state</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
<script src="../../iron-test-helpers/mock-interactions.js"></script>
|
||||
|
||||
<link rel="import" href="../../polymer/polymer.html">
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="test-elements.html">
|
||||
</head>
|
||||
<body>
|
||||
<test-fixture id="TrivialActiveState">
|
||||
<template>
|
||||
<test-button></test-button>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="ToggleActiveState">
|
||||
<template>
|
||||
<test-button toggles></test-button>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('active-state', function() {
|
||||
var activeTarget;
|
||||
|
||||
setup(function() {
|
||||
activeTarget = fixture('TrivialActiveState');
|
||||
});
|
||||
|
||||
suite('active state with toggles attribute', function() {
|
||||
setup(function() {
|
||||
activeTarget = fixture('ToggleActiveState');
|
||||
});
|
||||
|
||||
suite('when clicked', function() {
|
||||
test('is activated', function(done) {
|
||||
MockInteractions.downAndUp(activeTarget, function() {
|
||||
try {
|
||||
expect(activeTarget.hasAttribute('active')).to.be.eql(true);
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('is deactivated by a subsequent click', function(done) {
|
||||
MockInteractions.downAndUp(activeTarget, function() {
|
||||
MockInteractions.downAndUp(activeTarget, function() {
|
||||
try {
|
||||
expect(activeTarget.hasAttribute('active')).to.be.eql(false);
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('without toggles attribute', function() {
|
||||
suite('when mouse is down', function() {
|
||||
test('does not get an active attribute', function() {
|
||||
expect(activeTarget.hasAttribute('active')).to.be.eql(false);
|
||||
MockInteractions.down(activeTarget);
|
||||
expect(activeTarget.hasAttribute('active')).to.be.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
suite('when mouse is up', function() {
|
||||
test('does not get an active attribute', function() {
|
||||
MockInteractions.down(activeTarget);
|
||||
expect(activeTarget.hasAttribute('active')).to.be.eql(false);
|
||||
MockInteractions.up(activeTarget);
|
||||
expect(activeTarget.hasAttribute('active')).to.be.eql(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('when space is pressed', function() {
|
||||
test('triggers a click event', function(done) {
|
||||
activeTarget.addEventListener('click', function() {
|
||||
done();
|
||||
});
|
||||
MockInteractions.pressSpace(activeTarget);
|
||||
});
|
||||
|
||||
test('only triggers click after the key is released', function(done) {
|
||||
var keyupTriggered = false;
|
||||
|
||||
activeTarget.addEventListener('keyup', function() {
|
||||
keyupTriggered = true;
|
||||
});
|
||||
|
||||
activeTarget.addEventListener('click', function() {
|
||||
try {
|
||||
expect(keyupTriggered).to.be.eql(true);
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
|
||||
MockInteractions.pressSpace(activeTarget);
|
||||
});
|
||||
});
|
||||
|
||||
suite('when enter is pressed', function() {
|
||||
test('triggers a click event', function(done) {
|
||||
activeTarget.addEventListener('click', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
MockInteractions.pressEnter(activeTarget);
|
||||
});
|
||||
|
||||
test('only triggers click before the key is released', function(done) {
|
||||
var keyupTriggered = false;
|
||||
|
||||
activeTarget.addEventListener('keyup', function() {
|
||||
keyupTriggered = true;
|
||||
});
|
||||
|
||||
activeTarget.addEventListener('click', function() {
|
||||
try {
|
||||
expect(keyupTriggered).to.be.eql(false);
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
|
||||
MockInteractions.pressEnter(activeTarget);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,85 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>disabled-state</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../polymer/polymer.html">
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="test-elements.html">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="TrivialDisabledState">
|
||||
<template>
|
||||
<test-control></test-control>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="InitiallyDisabledState">
|
||||
<template>
|
||||
<test-control disabled></test-control>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('disabled-state', function() {
|
||||
var disableTarget;
|
||||
|
||||
suite('a trivial disabled state', function() {
|
||||
setup(function() {
|
||||
disableTarget = fixture('TrivialDisabledState');
|
||||
});
|
||||
|
||||
suite('when disabled is true', function() {
|
||||
test('receives a disabled attribute', function() {
|
||||
disableTarget.disabled = true;
|
||||
expect(disableTarget.hasAttribute('disabled')).to.be.eql(true);
|
||||
});
|
||||
|
||||
test('receives an appropriate aria attribute', function() {
|
||||
disableTarget.disabled = true;
|
||||
expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true');
|
||||
});
|
||||
});
|
||||
|
||||
suite('when disabled is false', function() {
|
||||
test('loses the disabled attribute', function() {
|
||||
disableTarget.disabled = true;
|
||||
expect(disableTarget.hasAttribute('disabled')).to.be.eql(true);
|
||||
disableTarget.disabled = false;
|
||||
expect(disableTarget.hasAttribute('disabled')).to.be.eql(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('a state with an initially disabled target', function() {
|
||||
setup(function() {
|
||||
disableTarget = fixture('InitiallyDisabledState');
|
||||
});
|
||||
|
||||
test('preserves the disabled attribute on target', function() {
|
||||
expect(disableTarget.hasAttribute('disabled')).to.be.eql(true);
|
||||
expect(disableTarget.disabled).to.be.eql(true);
|
||||
});
|
||||
|
||||
test('adds `aria-disabled` to the target', function() {
|
||||
expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,120 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>focused-state</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
<script src="../../iron-test-helpers/mock-interactions.js"></script>
|
||||
|
||||
<link rel="import" href="../../polymer/polymer.html">
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="test-elements.html">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="TrivialFocusedState">
|
||||
<template>
|
||||
<test-control tabindex="-1"></test-control>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="NestedFocusedState">
|
||||
<template>
|
||||
<nested-focusable></nested-focusable>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('focused-state', function() {
|
||||
var focusTarget;
|
||||
|
||||
setup(function() {
|
||||
focusTarget = fixture('TrivialFocusedState');
|
||||
});
|
||||
|
||||
suite('when is focused', function() {
|
||||
test('receives a focused attribute', function() {
|
||||
expect(focusTarget.hasAttribute('focused')).to.be.eql(false);
|
||||
MockInteractions.focus(focusTarget);
|
||||
expect(focusTarget.hasAttribute('focused')).to.be.eql(true);
|
||||
});
|
||||
|
||||
test('focused property is true', function() {
|
||||
expect(focusTarget.focused).to.not.be.eql(true);
|
||||
MockInteractions.focus(focusTarget);
|
||||
expect(focusTarget.focused).to.be.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
suite('when is blurred', function() {
|
||||
test('loses the focused attribute', function() {
|
||||
MockInteractions.focus(focusTarget);
|
||||
expect(focusTarget.hasAttribute('focused')).to.be.eql(true);
|
||||
MockInteractions.blur(focusTarget);
|
||||
expect(focusTarget.hasAttribute('focused')).to.be.eql(false);
|
||||
});
|
||||
|
||||
test('focused property is false', function() {
|
||||
MockInteractions.focus(focusTarget);
|
||||
expect(focusTarget.focused).to.be.eql(true);
|
||||
MockInteractions.blur(focusTarget);
|
||||
expect(focusTarget.focused).to.be.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
suite('when the focused state is disabled', function() {
|
||||
setup(function() {
|
||||
focusTarget.disabled = true;
|
||||
});
|
||||
|
||||
test('will not be focusable', function() {
|
||||
expect(focusTarget.getAttribute('tabindex')).to.be.eql('-1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('nested focusable', function() {
|
||||
var focusable;
|
||||
|
||||
setup(function() {
|
||||
focusable = fixture('NestedFocusedState');
|
||||
});
|
||||
|
||||
test('focus/blur events fired on host element', function(done) {
|
||||
var nFocusEvents = 0;
|
||||
var nBlurEvents = 0;
|
||||
focusable.addEventListener('focus', function() {
|
||||
nFocusEvents += 1;
|
||||
// setTimeout to wait for potentially more, erroneous events
|
||||
setTimeout(function() {
|
||||
assert.equal(nFocusEvents, 1, 'one focus event fired');
|
||||
MockInteractions.blur(focusable.$.input);
|
||||
});
|
||||
});
|
||||
focusable.addEventListener('blur', function() {
|
||||
nBlurEvents += 1;
|
||||
// setTimeout to wait for potentially more, erroneous events
|
||||
setTimeout(function() {
|
||||
assert.equal(nBlurEvents, 1, 'one blur event fired');
|
||||
done();
|
||||
});
|
||||
});
|
||||
MockInteractions.focus(focusable.$.input);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
'focused-state.html',
|
||||
'active-state.html',
|
||||
'disabled-state.html'
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,66 @@
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../iron-control-state.html">
|
||||
<link rel="import" href="../iron-button-state.html">
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-control',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronControlState
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-button',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronControlState,
|
||||
Polymer.IronButtonState
|
||||
],
|
||||
|
||||
_buttonStateChanged: function() {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<dom-module id="nested-focusable">
|
||||
|
||||
<template>
|
||||
<input id="input">
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'nested-focusable',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronControlState
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user