Skip to content

Instantly share code, notes, and snippets.

@ymrl
Created March 26, 2014 13:42
Show Gist options
  • Save ymrl/9783401 to your computer and use it in GitHub Desktop.
Save ymrl/9783401 to your computer and use it in GitHub Desktop.
Safari Password Auto-complete Test
require 'sinatra'
get('/') { erb :index }
post('/') { erb :index }
get("/login") { erb :login }
get("/other_with_password") { erb :other_with_password }
get("/same_name_with_password") { erb :same_name_with_password }
get("/same_name_with_another_password") { erb :same_name_with_another_password }
get("/same_name_with_password_and_disabled_password") { erb :same_name_with_password_and_disabled_password }
get("/disabled_password_hidden") { erb :disabled_password_hidden }
get("/disabled_password_0px") { erb :disabled_password_0px }
get("/disabled_password_1px") { erb :disabled_password_1px }
get("/final_solution") { erb :final_solution }
helpers do
def h(text)
Rack::Utils.escape_html(text)
end
end
__END__
@@layout
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<%= yield %>
</body>
</html>
@@index
<h1>index</h1>
<ul>
<li><a href="/login">login</a></li>
<li><a href="/other_with_password">other_with_password</a></li>
<li><a href="/same_name_with_password">same_name_with_password</a></li>
<li><a href="/same_name_with_another_password">same_name_with_another_password</a></li>
<li><a href="/same_name_with_password_and_disabled_password">same_name_with_password_and_disabled_password</a></li>
<li><a href="/disabled_password_hidden">disabled_password_hidden</a></li>
<li><a href="/disabled_password_0px">disabled_password_0px</a></li>
<li><a href="/disabled_password_1px">disabled_password_1px</a></li>
<li><a href="/final_solution">final_solution</a></li>
</ul>
<h1>params</h1>
<dl>
<% params.each_pair do |k,v| %>
<dt><%= h k %></dt>
<dt><%= h v %></dt>
<% end %>
</dl>
@@login
<form method="post" action="/">
<div>
<label>
username
<input type="text" name="username" />
</label>
</div>
<div>
<label>
password
<input type="password" name="password" />
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@other_with_password
<form method="post" action="/" autocomplete="off">
<div>
<label>
a field
<input type="text" name="a_field" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="another_field" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="a_password" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@same_name_with_password
<form method="post" action="/" autocomplete="off">
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@same_name_with_another_password
<form method="post" action="/" autocomplete="off">
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@same_name_with_password_and_disabled_password
<form method="post" action="/" autocomplete="off">
<input type="password" name="dummy" disabled="disabled"/>
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@disabled_password_hidden
<form method="post" action="/" autocomplete="off">
<input type="password" name="dummy" disabled="disabled" style="display:none"/>
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@disabled_password_0px
<form method="post" action="/" autocomplete="off" autocomplete="off">
<input type="password" name="dummy" disabled="disabled" style="width:0px;height:0px"/>
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@disabled_password_1px
<form method="post" action="/" autocomplete="off">
<input type="password" name="dummy" disabled="disabled" style="width:1px;height:1px"/>
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
@@final_solution
<form method="post" action="/" autocomplete="off">
<input type="text" name="dummy_text" disabled="disabled" style="width:2px;height:2px;position:absolute;opacity:0"/>
<input type="password" name="dummy_password" disabled="disabled" style="width:2px;height:2px;position:absolute;opacity:0"/>
<div>
<label>
a field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
another field
<input type="text" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<label>
a password
<input type="password" name="field[]" autocomplete="off"/>
</label>
</div>
<div>
<input type="submit" />
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment