Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1457)

Side by Side Diff: polymer_1.2.3/bower_components/iron-page-url/test/iron-page-url.html

Issue 1581713003: [third_party] add polymer 1.2.3 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: 1.2.3 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <!--
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 -->
10 <html>
11 <head>
12 <title>iron-page-url</title>
13
14 <script src="../../webcomponentsjs/webcomponents.js"></script>
15 <script src="../../web-component-tester/browser.js"></script>
16
17 <link rel="import" href="../../polymer/polymer.html">
18 <link rel="import" href="../../promise-polyfill/promise-polyfill.html">
19 <link rel="import" href="../iron-page-url.html">
20 </head>
21 <body>
22
23 <script>
24 'use strict';
25
26 function timePasses(ms) {
27 return new Promise(function(resolve) {
28 window.setTimeout(function() {
29 resolve();
30 }, ms);
31 });
32 }
33
34 function tryUntilTrue(f) {
35 return new Promise(function(resolve) {
36 if (f()) {
37 resolve();
38 }
39 var interval = setInterval(function() {
40 if (f()) {
41 clearInterval(interval);
42 resolve();
43 }
44 }, 1);
45 });
46 }
47
48 var originalFlush = flush;
49 flush = function() {
50 return new Promise(function(resolve) {
51 originalFlush(resolve);
52 });
53 }
54
55 suite('<iron-page-url>', function () {
56 var initialUrl;
57 setup(function() {
58 initialUrl = window.location.href;
59 });
60 teardown(function(){
61 window.history.replaceState({}, '', initialUrl);
62 });
63
64 suite('when used solo', function() {
65 var urlElem;
66 setup(function() {
67 urlElem = document.createElement('iron-page-url');
68 urlElem.attached();
69 });
70 teardown(function() {
71 urlElem.detached();
72 });
73 test('basic functionality with #hash urls', function() {
74 // Initialized to the window location's hash.
75 expect(window.location.hash).to.be.equal(urlElem.hash);
76
77 // Changing the urlElem's hash changes the URL
78 urlElem.hash = '/lol/ok';
79 expect(window.location.hash).to.be.equal('#/lol/ok');
80
81 // Changing the hash via normal means changes the urlElem.
82 var anchor = document.createElement('a');
83 anchor.href = '#/wat';
84 document.body.appendChild(anchor);
85 anchor.click();
86 // In IE10 it appears that the hashchange event is asynchronous.
87 return timePasses(10).then(function() {
88 expect(urlElem.hash).to.be.equal('/wat');
89 });
90 });
91 test('basic functionality with paths', function() {
92 // Initialized to the window location's path.
93 expect(window.location.pathname).to.be.equal(urlElem.path);
94
95 // Changing the urlElem's path changes the URL
96 urlElem.path = '/foo/bar';
97 expect(window.location.pathname).to.be.equal('/foo/bar');
98
99 // Changing the path and sending a custom event on the window changes
100 // the urlElem.
101 window.history.replaceState({}, '', '/baz')
102 window.dispatchEvent(new CustomEvent('location-changed'));
103 expect(urlElem.path).to.be.equal('/baz');
104 });
105 test('basic functionality with ?key=value params', function() {
106 // Initialized to the window location's params.
107 expect(urlElem.query).to.be.eq('');
108
109 // Changing location.search and sending a custom event on the window
110 // changes the urlElem.
111 window.history.replaceState({}, '', '/?greeting=hello&target=world');
112 window.dispatchEvent(new CustomEvent('location-changed'));
113 expect(urlElem.query).to.be.equal('greeting=hello&target=world');
114
115 // Changing the urlElem's query changes the URL.
116 urlElem.query = 'greeting=hello&target=world&another=key';
117 expect(window.location.search).to.be.equal(
118 '?greeting=hello&target=world&another=key');
119 });
120 });
121 });
122
123 </script>
124 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698