Auto merge of #11656 - Ms2ger:reduce-dom-exposure, r=nox

Reduce the amount of dom code used outside the script crate.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11656)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-07 11:09:14 -05:00
commit 1e3edf3ca4
41 changed files with 166 additions and 161 deletions

View file

@ -5,3 +5,25 @@
extern crate net_traits;
#[cfg(test)] mod image;
#[test]
fn test_trim_http_whitespace() {
fn test_trim(in_: &[u8], out: &[u8]) {
let b = net_traits::trim_http_whitespace(in_);
assert_eq!(b, out);
}
test_trim(b"", b"");
test_trim(b" ", b"");
test_trim(b"a", b"a");
test_trim(b" a", b"a");
test_trim(b"a ", b"a");
test_trim(b" a ", b"a");
test_trim(b"\t", b"");
test_trim(b"a", b"a");
test_trim(b"\ta", b"a");
test_trim(b"a\t", b"a");
test_trim(b"\ta\t", b"a");
}

View file

@ -1,17 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use script::dom::bindings::str::ByteString;
#[test]
fn test_byte_string_move() {
let mut byte_str = ByteString::new(vec![0x73, 0x65, 0x72, 0x76, 0x6f]);
let mut byte_vec = byte_str.bytes();
assert_eq!(byte_vec, "servo".as_bytes());
assert_eq!(&*byte_str, &*Vec::<u8>::new());
byte_vec = byte_str.into();
assert_eq!(byte_vec, Vec::<u8>::new());
}

View file

@ -1,27 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use script::dom::xmlhttprequest::trim_http_whitespace;
#[test]
fn test_trim_http_whitespace() {
fn test_trim(in_: &[u8], out: &[u8]) {
let b = trim_http_whitespace(in_);
assert_eq!(b, out);
}
test_trim(b"", b"");
test_trim(b" ", b"");
test_trim(b"a", b"a");
test_trim(b" a", b"a");
test_trim(b"a ", b"a");
test_trim(b" a ", b"a");
test_trim(b"\t", b"");
test_trim(b"a", b"a");
test_trim(b"\ta", b"a");
test_trim(b"a\t", b"a");
test_trim(b"\ta\t", b"a");
}

View file

@ -13,7 +13,5 @@ extern crate url;
#[cfg(all(test, target_pointer_width = "64"))] mod size_of;
#[cfg(test)] mod textinput;
#[cfg(test)] mod dom {
mod bindings;
mod blob;
mod xmlhttprequest;
}