| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 EXPECT_TRUE(base::WriteFile(path, content.c_str(), content.size())); | 26 EXPECT_TRUE(base::WriteFile(path, content.c_str(), content.size())); |
| 27 return GURL("file:///" + path.AsUTF8Unsafe()); | 27 return GURL("file:///" + path.AsUTF8Unsafe()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Test the CrOS login screen resource loading mechanism. | 30 // Test the CrOS login screen resource loading mechanism. |
| 31 class ResourceLoaderBrowserTest : public InProcessBrowserTest { | 31 class ResourceLoaderBrowserTest : public InProcessBrowserTest { |
| 32 public: | 32 public: |
| 33 ResourceLoaderBrowserTest() {} | 33 ResourceLoaderBrowserTest() {} |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 36 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 37 // Needed to load file:// URLs in XHRs. | 37 // Needed to load file:// URLs in XHRs. |
| 38 command_line->AppendSwitch(switches::kDisableWebSecurity); | 38 command_line->AppendSwitch(switches::kDisableWebSecurity); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual void SetUpOnMainThread() OVERRIDE { | 41 virtual void SetUpOnMainThread() override { |
| 42 // Create the root page containing resource_loader.js. | 42 // Create the root page containing resource_loader.js. |
| 43 std::string root_page = | 43 std::string root_page = |
| 44 "<html>" | 44 "<html>" |
| 45 "<head>" | 45 "<head>" |
| 46 "<script>" | 46 "<script>" |
| 47 " cr = { ui: { login: {} } };" | 47 " cr = { ui: { login: {} } };" |
| 48 " cr.define = function (path, builder) {" | 48 " cr.define = function (path, builder) {" |
| 49 " cr.ui.login.ResourceLoader = builder();" | 49 " cr.ui.login.ResourceLoader = builder();" |
| 50 " };" | 50 " };" |
| 51 " $ = document.getElementById.bind(document);" | 51 " $ = document.getElementById.bind(document);" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 JSExpect("!!document.querySelector('div#root h1#bar')"); | 128 JSExpect("!!document.querySelector('div#root h1#bar')"); |
| 129 | 129 |
| 130 // Check that the JS was loaded and evaluated. | 130 // Check that the JS was loaded and evaluated. |
| 131 JSExpect("stuff.loaded"); | 131 JSExpect("stuff.loaded"); |
| 132 | 132 |
| 133 // Check that the styles were loaded. | 133 // Check that the styles were loaded. |
| 134 JSExpect("!!document.head.querySelector('link').innerHTML.indexOf('red')"); | 134 JSExpect("!!document.head.querySelector('link').innerHTML.indexOf('red')"); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| OLD | NEW |