Skip to content

Instantly share code, notes, and snippets.

@wpalmer
Created September 25, 2012 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpalmer/3780200 to your computer and use it in GitHub Desktop.
Save wpalmer/3780200 to your computer and use it in GitHub Desktop.
Sizzle quoted selector bisect -> af8206ff677909e61aec0158443ff74263e6265b
#!/usr/bin/env phantomjs
var page = require('webpage').create();
page.open("file:///Users/wpalmer/git/sizzle/t.html", function(status){
try {
phantom.exit(
page.evaluate(function(){
return window.Sizzle('p:eq("3")');
}).length !== 0
)
} catch(e) {
phantom.exit(0);
}
});
#!/bin/bash
# 831c9c489ef90134436449b5c732f93f0a0b29bb can use quotes in :eq(...)
# 4674e7ed7f0f19bcbaaf7710ba256db374c0dd9b [random point in the past] cannot use quotes in :eq(...)
# Trying to find first commit in which quotes can be used in :eq(...)
git bisect start 831c9c489ef90134436449b5c732f93f0a0b29bb 4674e7ed7f0f19bcbaaf7710ba256db374c0dd9b
git bisect run "$(dirname "$0")/bisect.js"
# the result was af8206ff677909e61aec0158443ff74263e6265b
# however, the parent of af8206ff677909e61aec0158443ff74263e6265b does not fail silently
# At what point did we go from "silently failing" to "explicitly not working" prior to "working"?
git bisect reset
git bisect start af8206ff677909e61aec0158443ff74263e6265b^ 4674e7ed7f0f19bcbaaf7710ba256db374c0dd9b
git bisect run "$(dirname "$0")/bisect2.js"
# the result was e89d06c4134ec439e52382acd0e569e97fed7ebc
#!/usr/bin/env phantomjs
var page = require('webpage').create();
page.open("file:///Users/wpalmer/git/sizzle/t.html", function(status){
try {
var match = page.evaluate(function(){
try {
return window.Sizzle('p:eq("3")');
} catch(e) {
return "EX";
}
});
if( match === "EX" ){
phantom.exit(1); // explicitly not parsed
} else {
phantom.exit(0); // fails silently
}
} catch(e) {
phantom.exit(125); //error
}
});
<html>
<head>
<script src="sizzle.js"></script>
<title>Title</title>
</head>
<body>
<div id="a">
<h1>Header a</h1>
<p>
First Paragraph
</p>
<p>
Second Paragraph
</p>
</div>
<div id="b">
<h1>Header b</h1>
<p>
Third Paragraph
</p>
<p>
Fourth Paragraph
</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment