Commit 8d441ea6 authored by Ian Briggs's avatar Ian Briggs
Browse files

Create elements fixes

parent 87e35e09
......@@ -29,13 +29,18 @@ Boilerplate.
Show the page with no content changes by scripts.
>>> web_url = 'http://test.test/chapter9-create-1/html'
>>> html = "<div>Some content</div> <p>More content</p>"
>>> script_url = 'http://test.test/chapter9-create-1/js'
>>> html = ("<script src=" + script_url + "></script>"
... + "<div>Some content </div> <p><b>More</b> content</p>")
>>> test.socket.respond_200(web_url, body=html)
>>> test.socket.respond_200(script_url, body="")
>>> this_browser = browser.Browser()
>>> this_browser.load(web_url)
>>> browser.print_tree(this_browser.tabs[0].document)
DocumentLayout()
BlockLayout(x=13, y=18, width=774, height=30.0)
InlineLayout(x=13, y=18, width=774, height=0)
LineLayout(x=13, y=18, width=774, height=0)
BlockLayout(x=13, y=18, width=774, height=30.0)
InlineLayout(x=13, y=18, width=774, height=15.0)
LineLayout(x=13, y=18, width=774, height=15.0)
......@@ -43,21 +48,21 @@ Show the page with no content changes by scripts.
TextLayout(x=73, y=20.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
InlineLayout(x=13, y=33.0, width=774, height=15.0)
LineLayout(x=13, y=33.0, width=774, height=15.0)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=bold slant=roman style=None)
TextLayout(x=73, y=35.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
Set up the webpage and script links.
Create a button and add it as a child to the `<body>` at the end.
Create an input and add it as a child to the `<p>` at the end.
>>> web_url = 'http://test.test/chapter9-create-2/html'
>>> script_url = 'http://test.test/chapter9-create-2/js'
>>> html = ("<script src=" + script_url + "></script>"
... + "<div>Some content</div> <p>More content</p>")
... + "<div>Some content </div> <p><b>More</b> content</p>")
>>> test.socket.respond_200(web_url, body=html)
>>> script = """
... new_elt = document.createElement("button");
... my_body = document.querySelectorAll('body')[0];
... my_body.appendChild(new_elt);
... new_elt = document.createElement("input");
... my_p = document.querySelectorAll('p')[0];
... my_p.appendChild(new_elt);
... """
>>> test.socket.respond_200(script_url, body=script)
>>> this_browser = browser.Browser()
......@@ -74,55 +79,22 @@ Create a button and add it as a child to the `<body>` at the end.
TextLayout(x=73, y=20.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
InlineLayout(x=13, y=33.0, width=774, height=15.0)
LineLayout(x=13, y=33.0, width=774, height=15.0)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=bold slant=roman style=None)
TextLayout(x=73, y=35.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
BlockLayout(x=13, y=48.0, width=774, height=0)
InputLayout(x=169, y=35.25, width=200, height=12)
Create a button and add it inside the `<body>` before the `<div>`
Create an input and add it inside the `<p>` before the `<b>`
>>> web_url = 'http://test.test/chapter9-create-3/html'
>>> script_url = 'http://test.test/chapter9-create-3/js'
>>> html = ("<script src=" + script_url + "></script>"
... + "<div>Some content</div> <p>More content</p>")
... + "<div>Some content </div> <p><b>More</b> content</p>")
>>> test.socket.respond_200(web_url, body=html)
>>> script = """
... new_elt = document.createElement("button");
... my_body = document.querySelectorAll('body')[0];
... my_div = document.querySelectorAll('div')[0];
... my_body.insertBefore(new_elt, my_div);
... """
>>> test.socket.respond_200(script_url, body=script)
>>> this_browser = browser.Browser()
>>> this_browser.load(web_url)
>>> browser.print_tree(this_browser.tabs[0].document)
DocumentLayout()
BlockLayout(x=13, y=18, width=774, height=30.0)
InlineLayout(x=13, y=18, width=774, height=0)
LineLayout(x=13, y=18, width=774, height=0)
BlockLayout(x=13, y=18, width=774, height=30.0)
BlockLayout(x=13, y=18, width=774, height=0)
InlineLayout(x=13, y=18, width=774, height=15.0)
LineLayout(x=13, y=18, width=774, height=15.0)
TextLayout(x=13, y=20.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=73, y=20.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
InlineLayout(x=13, y=33.0, width=774, height=15.0)
LineLayout(x=13, y=33.0, width=774, height=15.0)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=73, y=35.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
Create a button and add it inside the `<body>` before the `<p>`
>>> web_url = 'http://test.test/chapter9-create-4/html'
>>> script_url = 'http://test.test/chapter9-create-4/js'
>>> html = ("<script src=" + script_url + "></script>"
... + "<div>Some content</div> <p>More content</p>")
>>> test.socket.respond_200(web_url, body=html)
>>> script = """
... new_elt = document.createElement("button");
... my_body = document.querySelectorAll('body')[0];
... new_elt = document.createElement("input");
... my_p = document.querySelectorAll('p')[0];
... my_body.insertBefore(new_elt, my_p);
... my_b = document.querySelectorAll('b')[0];
... my_p.insertBefore(new_elt, my_b);
... """
>>> test.socket.respond_200(script_url, body=script)
>>> this_browser = browser.Browser()
......@@ -137,24 +109,24 @@ Create a button and add it inside the `<body>` before the `<p>`
LineLayout(x=13, y=18, width=774, height=15.0)
TextLayout(x=13, y=20.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=73, y=20.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
BlockLayout(x=13, y=33.0, width=774, height=0)
InlineLayout(x=13, y=33.0, width=774, height=15.0)
LineLayout(x=13, y=33.0, width=774, height=15.0)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=73, y=35.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
InputLayout(x=13, y=35.25, width=200, height=12)
TextLayout(x=225, y=35.25, width=48, height=12, font=Font size=12 weight=bold slant=roman style=None)
TextLayout(x=285, y=35.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
Create a button and add it inside the `<body>` at then end of its children
Create an input and add it inside the `<p>` at then end of its children
by using `insertBefore` with a reference node of null.
>>> web_url = 'http://test.test/chapter9-create-5/html'
>>> script_url = 'http://test.test/chapter9-create-5/js'
>>> html = ("<script src=" + script_url + "></script>"
... + "<div>Some content</div> <p>More content</p>")
... + "<div>Some content </div> <p><b>More</b> content</p>")
>>> test.socket.respond_200(web_url, body=html)
>>> script = """
... new_elt = document.createElement("button");
... my_body = document.querySelectorAll('body')[0];
... my_body.insertBefore(new_elt, null);
... new_elt = document.createElement("input");
... my_p = document.querySelectorAll('p')[0];
... my_p.insertBefore(new_elt, null);
... """
>>> test.socket.respond_200(script_url, body=script)
>>> this_browser = browser.Browser()
......@@ -171,6 +143,6 @@ by using `insertBefore` with a reference node of null.
TextLayout(x=73, y=20.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
InlineLayout(x=13, y=33.0, width=774, height=15.0)
LineLayout(x=13, y=33.0, width=774, height=15.0)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=normal slant=roman style=None)
TextLayout(x=13, y=35.25, width=48, height=12, font=Font size=12 weight=bold slant=roman style=None)
TextLayout(x=73, y=35.25, width=84, height=12, font=Font size=12 weight=normal slant=roman style=None)
BlockLayout(x=13, y=48.0, width=774, height=0)
InputLayout(x=169, y=35.25, width=200, height=12)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment