2728293031323334353637
{ Document d = new Document(); Environment env = mockEnvironment(); Asset asset = mockAsset(); d.newRootElement("foo"); String initial = d.toString(); train_peek(env, Document.class, d); replay();
4849505152535455565758
{ Document d = new Document(); Environment env = mockEnvironment(); Asset asset = mockAsset(); d.newRootElement("html").element("head"); train_peek(env, Document.class, d); train_toClientURL(asset, "{clientURL}");
2930313233343536373839
@Test public void do_nothing_if_no_body() { Document document = new Document(); document.newRootElement("not-html").text("not an HTML document"); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addScript("foo.js"); builder.addScript("doSomething();");
4647484950515253545556
@Test public void add_script_links() throws Exception { Document document = new Document(new XMLMarkupModel()); document.newRootElement("html").element("body").element("p").text( "Ready to be updated with scripts."); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addScriptLink("foo.js");
6465666768697071727374
@Test public void add_style_links() throws Exception { Document document = new Document(new XMLMarkupModel()); document.newRootElement("html").element("body").element("p").text( "Ready to be updated with styles."); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addStylesheetLink("foo.css", null);
8283848586878889909192
@Test public void duplicate_scripts_ignored_first_media_wins() throws Exception { Document document = new Document(new XMLMarkupModel()); document.newRootElement("html").element("body").element("p").text( "Ready to be updated with styles."); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addStylesheetLink("foo.css", null);
103104105106107108109110111112113
@Test public void existing_head_used_if_present() throws Exception { Document document = new Document(new XMLMarkupModel()); document.newRootElement("html").element("head").comment("existing head").getParent() .element("body").text("body content"); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addStylesheetLink("foo.css", null);
120121122123124125126127128129130
@Test public void duplicate_script_links_ignored() throws Exception { Document document = new Document(); document.newRootElement("html").element("body").element("p").text( "Ready to be updated with scripts."); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); for (int i = 0; i < 3; i++)
142143144145146147148149150151152
@Test public void add_script() throws Exception { Document document = new Document(); document.newRootElement("html").element("body").element("p").text( "Ready to be updated with scripts."); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addScript("doSomething();");
163164165166167168169170171172173
@Test public void no_body_element() throws Exception { Document document = new Document(new XMLMarkupModel()); document.newRootElement("html").element("notbody").element("p").text( "Ready to be updated with scripts."); DocumentHeadBuilder builder = new DocumentHeadBuilderImpl(); builder.addScriptLink("foo.js");